Skip to content

Commit

Permalink
only apply client header fix when using graphiql
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed May 21, 2020
1 parent bad2631 commit 57ba75c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
17 changes: 7 additions & 10 deletions demo/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ app.use(

// removes a little bit of hassle from manually testing the api
app.use((req, res, next) => {
req.headers['client-id'] = 'treecreeper-demo';
next()
})
if (/\/graphiql$/.test(req.headers.referer)) {
req.headers['client-id'] = 'treecreeper-demo';
}
next();
});

getApp({
treecreeperPath: '/api',
Expand All @@ -42,18 +44,13 @@ getApp({
});

require('@babel/register'); // eslint-disable-line import/no-extraneous-dependencies
const {
editController,
viewController,
deleteController,
anotherController,
} = require('./cms');
const { editController, viewController, deleteController } = require('./cms');

const parseBody = bodyParser.urlencoded({ limit: '8mb', extended: true });
app.get('/', (req, res) => {
res.send(`<html><head></head><body>
<a href="/graphiql">GraphQL explorer.</a>
</body></html>`)
</body></html>`);
});
app.get('/:type/:code/edit', editController);
app.post('/:type/:code/edit', parseBody, editController);
Expand Down
1 change: 0 additions & 1 deletion demo/cms/index.jsx → demo/cms/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const React = require('react');
const logger = require('@financial-times/lambda-logger');
const { getCMS } = require('@financial-times/tc-ui');

Expand Down

0 comments on commit 57ba75c

Please sign in to comment.