Authorization header not making it through Apollo Server #4138
-
My mesh server is working fine with the default Yoga server integration, but when I add a custom Apollo Server handler, the authorization header is sent to my OpenAPI server as an empty string. I realized the HTTP headers in the openapi:
baseUrl: https://localhost/v2/
source: ....
operationHeaders:
Authorization: '{context.headers.authorization}' to openapi:
baseUrl: https://localhost/v2/
source: ....
operationHeaders:
Authorization: '{context.req.headers.get("authorization")}' The debug logs show the outgoing request to be:
Note that I am also using a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I was able to fix it by storing the header info in custom const apolloServer = new ApolloServer({
schema,
executor: async requestContext => {
const { schema, execute, contextFactory } = getEnveloped({ req: requestContext.request.http })
const context = await contextFactory();
context.authorization = context.req.headers.get('authorization');
return execute({
schema: schema,
document: requestContext.document,
contextValue: context,
variableValues: requestContext.request.variables,
operationName: requestContext.operationName
})
} and then in the operationHeaders:
Authorization: "{context.authorization}" |
Beta Was this translation helpful? Give feedback.
I was able to fix it by storing the header info in custom
context
value asauthorization
like this:and then in the
.meshrc.yml
file:operat…