DEV Community

Discussion on: CORS in Apollo Client & Apollo Server

Collapse
 
radhasatam profile image
Radha Satam

Why not just add corsOptions on server.applyMiddleware

const corsOptions = {
  origin: 'http://localhost:3000',
  credentials: true
}
Enter fullscreen mode Exit fullscreen mode

This worked for me and I didn't have to use the cors dependency

server.applyMiddleware({ app, cors: corsOptions });
Enter fullscreen mode Exit fullscreen mode
Collapse
 
theknary profile image
knary

This is the only method I got cors to work with. Thanks!

Collapse
 
mwangikibui profile image
mwangiKibui

Worked out too. Thanks.