-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ApolloServer.applyMiddleware doesn't support OPTIONS requests #2253
Comments
I would happily review a PR which adds this! There are implementations of this in other integrations (it is missing from For example, the Azure Functions integration : apollo-server/packages/apollo-server-azure-functions/src/ApolloServer.ts Lines 116 to 124 in 6c87cbc
...and in the Google Cloud Functions implementation as well: apollo-server/packages/apollo-server-cloud-functions/src/ApolloServer.ts Lines 118 to 122 in b61dee3
|
It looks like OPTIONS is working for -express (I just checked against fullstack-tutorial) I would guess the cors middleware is handling OPTIONS automatically apollo-server/packages/apollo-server-express/src/ApolloServer.ts Lines 148 to 152 in 2f77362
It looks like there are similar lines in -koa apollo-server/packages/apollo-server-koa/src/ApolloServer.ts Lines 149 to 153 in 2f77362
I wonder if '@koa/cors' should handle this? |
Ah, that makes sense. I guess some integrations handle it at another level. Thanks for pointing this out, @cheapsteak! |
As far as I know, it only applies to Koa integration. Could be for other integrations, too.
ApolloServer.applyMiddleware
only add middleware to support GET and POST requests. It should also support OPTIONS. Otherwise it will break setup when client and server are on different hosts.Why does it matter? Given you want to access GraphQL server (at
graphql.local
) on web client (atfrontend.local
) browser will send OPTIONS request before any user request to make suregraphql.local
accepts requests made fromfrontend.local
(viaAccess-Control-Allow-Origin
header).The text was updated successfully, but these errors were encountered: