-
Notifications
You must be signed in to change notification settings - Fork 9
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
Set CORS headers #39
Comments
Or is the theory that if you're using API Gateway you would just enable CORS via API Gateway rather than in the function? |
We suspect that this issue is caused by the fact that Apollo Server v4 no longer has an interface to directly link express middleware. Currently, the cheapest solution is to wrap async function handler(event: GatewayEvent, context: Context, callback: Callback<APIGatewayProxyStructuredResultV2 | APIGatewayProxyResult>) {
const apolloHandler = startServerAndCreateLambdaHandler(server);
const resp = await apolloHandler(event, context, callback);
return {
...resp,
headers: {
...resp?.headers,
'Access-Control-Allow-Origin': '*',
},
};
}
export default handler; If possible, it would be great if |
Yes, though if you enjoyed that interface, you can see #38 for an alternate approach that doesn't use this package (and which is powered by the same package that powered |
You can now use middleware to mutate headers on the way out with v2.0.0! See README for more info! |
This "callback function" is now implemented as middlware in the new version! |
Because the handler exposed by this package is not a modular piece of middleware, it probably makes sense for it to function like
startStandaloneServer
and have the default behavior of settingaccess-control-allow-origin: *
and friends. (Then potentially layer some mechanism for CORS configuration on top of that, or just tell people who need more configuration to do something like #38.)The text was updated successfully, but these errors were encountered: