From feb82b5870c93000b9f1a3d9ab0645c36038e768 Mon Sep 17 00:00:00 2001 From: ryzetech Date: Fri, 20 Jan 2023 08:45:56 +0100 Subject: [PATCH] changed middleware order to allow preflight --- app.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 897bf34..2e1f031 100644 --- a/app.js +++ b/app.js @@ -43,12 +43,22 @@ let root = { }; let app = express(); + +/* leaving this here for reference +app.options('/graphql', function (req, res) { + res.header('Access-Control-Allow-Origin', '*'); + res.header('Access-Control-Allow-Methods', 'GET,POST,OPTIONS'); + res.send(200); +}); +*/ + +app.use(cors()); + app.use('/graphql', graphqlHTTP({ schema: schema, rootValue: root, graphiql: true, })); -app.use(cors()); app.listen(config.port || 4000);