Apollo server CORS error

I have set up the apollo server as below with COSE options

server.applyMiddleware({ app, path: graphqlPath, cors: corsOptions });

But I am getting the following errror. :confused:

Access to fetch at 'http://localhost:3000/graphql' from origin 'http://localhost:3001' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.

I also have the express app setup as follows


But if I set cors: false in apollo server it works
Why can’t i use CORS in the apollo server

Your request is considered “cross domain” since the ports don’t match.

The error is helpful in this case; you have a couple options. I would prefer the second.

I suppose you want your cors setting to be:

cors: {
  origin: ["http://localhost:3001"]