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;

View File

@@ -56,7 +56,7 @@ class Payload {
this.config.routes.graphQL,
createAuthHeaderFromCookie,
passport.authenticate(['jwt', 'anonymous'], { session: false }),
new GraphQL(this.config, this.collections, this.User, this.Upload, this.globals),
new GraphQL(this.config, this.collections, this.User, this.Upload, this.globals).init(),
);
this.router.get(this.config.routes.graphQLPlayground, graphQLPlayground({

View File

@@ -11,6 +11,7 @@ const connectMongoose = async (url) => {
urlToConnect = await mongod.getUri();
successfulConnectionMessage = 'Connected to in-memory Mongo server successfully!';
}
mongoose.connect(urlToConnect, {
useNewUrlParser: true,
useUnifiedTopology: true,