changed middleware order to allow preflight
This commit is contained in:
parent
2a30091335
commit
feb82b5870
1 changed files with 11 additions and 1 deletions
12
app.js
12
app.js
|
@ -43,12 +43,22 @@ let root = {
|
||||||
};
|
};
|
||||||
|
|
||||||
let app = express();
|
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({
|
app.use('/graphql', graphqlHTTP({
|
||||||
schema: schema,
|
schema: schema,
|
||||||
rootValue: root,
|
rootValue: root,
|
||||||
graphiql: true,
|
graphiql: true,
|
||||||
}));
|
}));
|
||||||
app.use(cors());
|
|
||||||
|
|
||||||
app.listen(config.port || 4000);
|
app.listen(config.port || 4000);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue