I am following this link to deploy an Apollo GraphQL Server with Amplify Functions: https://dev.to/aws/10-minute-tutorial-deploy-an-apollo-graphql-server-with-amplify-functions-38p1
However, when I run "npm start", it fails to access 'http://localhost:3000', showing:
Access to fetch at 'https://******.execute-api.us-east-1.amazonaws.com/dev/graphql'
from origin 'http://localhost:3000' 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.
Failed to load resource: net::ERR_FAILED
******.execute-api.us-east-1.amazonaws.com/dev/graphql:1
Here is how I set exports handler in index.js for Lambda:
exports.handler = server.createHandler({
cors: {
origin: "*",
credentials: true, // I tried setting false is also the same
},
});
I am not sure whether CORS is the root cause because I think the above config should make it work. I suspect that something going wrong for API end point. I see the failure using browser to access REST API endpoint, which is the link in aws-exports.js:
awsmobile.aws_cloud_logic_custom[0] = "******.execute-api.us-east-1.amazonaws.com/dev"
It shows:
{"message":"Missing Authentication Token"}
And I cannot access "******.execute-api.us-east-1.amazonaws.com/dev/graphql" either, showing:
{"message": "Internal server error"}
Is it because of missing AWS signature? Anything else I need to config for authentication?