From 3e51f38bb115db19cf60f6c7badc2a29c8b12d3d Mon Sep 17 00:00:00 2001 From: DAB0mB Date: Mon, 1 Apr 2019 13:22:19 +0800 Subject: [PATCH] Step 8.4: Support credentials --- index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 11802a0ba..bc8c74139 100644 --- a/index.ts +++ b/index.ts @@ -7,7 +7,8 @@ import schema from './schema'; const app = express(); -app.use(cors()); +const origin = process.env.ORIGIN || 'http://localhost:3000'; +app.use(cors({ credentials: true, origin })); app.use(express.json()); app.get('/_ping', (req, res) => { @@ -26,6 +27,7 @@ const server = new ApolloServer({ server.applyMiddleware({ app, path: '/graphql', + cors: { credentials: true, origin }, }); const httpServer = http.createServer(app);