changed middleware order to allow preflight

This commit is contained in:
ryzetech 2023-01-20 08:45:56 +01:00
parent 2a30091335
commit feb82b5870

12
app.js
View file

@ -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);