Изучаю react/node по курсу udemy. Локально все работает нормально, но после деплоя при попытке Login with Google, консоль выдает ошибку:
Failed to load resource: the server responded with a status of 503 (Service Unavailable)
Access to fetch at '
https://geostickers.herokuapp.com/graphql' from origin '
https://geoapp-pvfinzglt.now.sh' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Error logging in TypeError: Failed to fetch
Ошибку можно сгенерировать на клиенте
https://geoapp-pvfinzglt.now.sh
Код сервера:
const server = new ApolloServer({
typeDefs,
resolvers,
//cors: true, - не решает проблему
context: async ({ req }) => {
let authToken = null;
let currentUser = null;
try {
authToken = req.headers.authorization
if(authToken) {
currentUser = await findOrCreateUser(authToken);
}
} catch(err) {
console.error(`Unable to authenticate user with token ${authToken}`)
}
return { currentUser }
}
});
server.listen({ port: process.env.PORT || 4000 }).then(({ url }) => {
console.log(`Server listening on ${url}`)
});