the case of the missing file

This commit is contained in:
James
2020-04-16 13:32:47 -04:00
parent 9271b97cf1
commit 5699bb6ecd
3 changed files with 16 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
const createAuthHeaderFromCookie = (req, _, next) => {
if (process.env.NODE_ENV !== 'production' || this.config.productionGraphQLPlayground) {
const existingAuthHeader = req.get('Authorization');
const { token } = req.cookies;
if (!existingAuthHeader && token) {
req.headers.authorization = `JWT ${token}`;
}
}
next();
};
module.exports = createAuthHeaderFromCookie;