-
Notifications
You must be signed in to change notification settings - Fork 4
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
Why are my cors headers being ignored? #77
Comments
This allows custom cors behaviour with Apollo4,
I experimented with a few other arrangements, such as cors after koaMiddleware etc this was the only arrangement that succeeded here using apollo4 app.use(async (ctx, next) => {
// apollo4 downstream must process first before headers attached
if (apollo4Koa) await next();
ctx = attachCorsHeaders(ctx);
return ctx;
}); Something like this seems to be happening. Problematic cors behaviour is not found by Apollo4 developers, because Apollo4 is tested with @koa/cors, which always calls next() when request method is not OPTIONS. If cors headers are attached before the Apollo4 middleware are run, Apollo removes the headers or has some other problem. The apollo middleware must run last, forcing cors middleware do be attached before apollo. |
I am a little busy this week but will try and look into this more, in the mean time please feel free to open a PR they are more than welcome! |
@iambumblehead I don't quite follow what your exact issue is. This seems relevant but I can't quite piece together what the actual problem is:
Are you suggesting that |
When doing an introspection query, the koa integrated service seems to ignore the cors headers being set by the aplication. Cors headers are set this way,
Using the new apollo server integration, cors requests are failing here, and introspection queries from different hosts fail
app.js
thanks for any reply you may give
The text was updated successfully, but these errors were encountered: