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,
ctx.status = 200;
ctx.set('access-control-allow-credentials', 'true');
ctx.set('access-control-allow-origin', host);
ctx.set('access-control-allow-headers', corsHeadersAccepted);
ctx.set('access-control-allow-methods', 'OPTIONS');
ctx.set('access-control-allow-methods', 'GET,HEAD,PUT,POST,DELETE,OPTIONS');
/*
response: {
status: 200,
message: 'OK',
header: [Object: null prototype] {
'access-control-allow-credentials': 'true',
'access-control-allow-origin': 'http://localhost:3001',
'access-control-allow-headers': 'content-type,authorization,accept,accept-language',
'access-control-allow-methods': 'GET,HEAD,PUT,POST,DELETE,OPTIONS'
}
}
*/
Using the new apollo server integration, cors requests are failing here, and introspection queries from different hosts fail
app.js
const apolloServer = new ApolloServer({
schema: executableSchema,
formatError: (formattedError, error) => ({
console.log(error.extensions.http.headers) // { status: 400, headers: HeaderMap(0) [Map] {} }
console.log(error)
// BadRequestError [GraphQLError]: This operation has been blocked as a potential
// Cross-Site Request Forgery (CSRF). Please either specify a 'content-type' header
// (with a type that is not one of application/x-www-form-urlencoded,
// multipart/form-data, text/plain) or provide a non-empty value for one of the
// following headers: x-apollo-operation-name, apollo-require-preflight
return formattedError;
})
})
thanks for any reply you may give
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