Skip to content

Commit

Permalink
fix: revert cors applied
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Oct 3, 2019
1 parent 581816e commit 943b2bf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
15 changes: 6 additions & 9 deletions packages/@nodepack/plugin-apollo/src/runtime/apollo-express.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,8 @@ hook('expressHttp', async (ctx) => {
},
}))

// Express middleware
const graphqlPath = apolloConfig.path || '/graphql'
server.setGraphQLPath(graphqlPath)
app.use(server.getMiddleware({
path: graphqlPath,
cors: config.cors,
}))

hook('expressCors', ctx => {
ctx.corsApplied = true
})

// GraphQL Playground
if (apolloConfig.playground !== false) {
Expand All @@ -61,6 +52,12 @@ hook('expressHttp', async (ctx) => {
}))
}

// Express middleware
app.use(server.getMiddleware({
path: graphqlPath,
cors: config.cors,
}))

// Subscriptions
server.installSubscriptionHandlers(httpServer)

Expand Down
4 changes: 1 addition & 3 deletions packages/@nodepack/plugin-express/src/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ hook('bootstrap', async (ctx) => {

// CORS
if ('cors' in ctx.config) {
app.use(cors(ctx.config.cors))
await callHook('expressCors', ctx)
if (!ctx.corsApplied) {
app.use(cors(ctx.config.cors))
}
}

// Cookies
Expand Down
2 changes: 1 addition & 1 deletion packages/@nodepack/plugin-passport/src/runtime/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function setupPassport (ctx) {
serialized,
})
if (!user) {
done(null, false)
return done(null, false)
}
done(null, user)
} catch (e) {
Expand Down

0 comments on commit 943b2bf

Please sign in to comment.