Any ideas how I can resolve cors issue?
# orm-help
g
Any ideas how I can resolve cors issue?
Here is an error:
Copy code
Access to fetch at '...' from origin '<http://localhost:3000>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
The server is on
graphql-yoga
, deployed to heroku (on local machine everything works great, no such issue). I tried to imprort
cors
package and use it like that:
server.express.use('/*', cors());
but it didn't help.
g
@Fran Dios I did it like that and it still works the same way:
Copy code
server.start(
  {
    cors: {
      origin: [/\.netlify\.com.*/, /localhost:.*/],
    },
  },
  ({ port }) => console.log(`GraphQL server is running on the port ${port}`),
);