CORS issue - API and web on different domains

Hi @leoalbin.

If CORS is enabled per apollo-server-lambda’s instructions I confirmed that I did get the response headers … I just inspected http://localhost:8911/graphql for a quick check.

Before Change

Screenshot 2020-07-31 07.08.01

After Change

Screenshot 2020-07-31 07.11.53

The Change

In redwoodjs/redwood/packages/api/src/functions/graphql.ts, add cors options in createHandler:

createHandler({
    cors: {
      origin: '*',
      credentials: true,
    },
  })

I’ll tried to enable CORS via the createGraphQLHandler’s callback and options but no luck (but I may not be doing it correctly).

I wonder @peterp if CORS should be enabled as the default behavior? Or perhaps make it an option to set origin: true or origin: * and the credentials?

1 Like