Browse Source

auth token fixes

Ivan Asmer 5 years ago
parent
commit
0915fc7221
1 changed files with 2 additions and 2 deletions
  1. 2 2
      index.js

+ 2 - 2
index.js

@@ -386,14 +386,14 @@ const anonResolvers = ['login', 'createUser'];
     }
 
     app.use('/graphql', express_graphql(async (req, res, gql) => { 
-        if (gql.operationName === null || anonResolvers.includes(gql.operationName))
+        const authorization = req.headers.authorization 
+        if (!authorization && (gql.operationName === null || anonResolvers.includes(gql.operationName)))
             return {
                 schema: schema,
                 rootValue: rootResolvers,
                 graphiql: true, 
             }
         
-        const authorization = req.headers.authorization 
         if (authorization && authorization.startsWith('Bearer ')){
             console.log('token provided')
             const token = authorization.substr("Bearer ".length)