Skip to content

Commit c99037d

Browse files
committed
fix(GraphQLServerLambda): add null check for event headers
1 parent b88a125 commit c99037d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/lambda.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ export class GraphQLServerLambda {
5050

5151
graphqlHandler = (event, context, callback) => {
5252
function callbackFilter(error, output) {
53+
const headers = output.headers || {}
54+
headers['Access-Control-Allow-Origin'] = '*'
55+
5356
// eslint-disable-next-line no-param-reassign
54-
output.headers['Access-Control-Allow-Origin'] = '*'
57+
output.headers = headers
5558

5659
callback(error, output)
5760
}
@@ -61,7 +64,7 @@ export class GraphQLServerLambda {
6164
if (typeof t === 'boolean') {
6265
return t
6366
} else if (t.mode === 'http-header') {
64-
return event.headers['x-apollo-tracing'] !== undefined
67+
return event.headers && event.headers['x-apollo-tracing'] !== undefined
6568
} else {
6669
return t.mode === 'enabled'
6770
}

0 commit comments

Comments
 (0)