GraphQL Invalid IAP credentials: empty token
Tech stacks:
- Google app engine with Identity-Aware Proxy turned on
- GraphQL with Apollo Server Express
Problem
- Cannot enable playground in production
- Appolo Docs
const { ApolloServer } = require('apollo-server');
const { typeDefs, resolvers } = require('./schema');
const server = new ApolloServer({
typeDefs,
resolvers,
introspection: true,
playground: true,
});
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
Cause
- Request POST
/graphql
return 401 errors
Digging in that request we got"credentials": "omit"
Solution
...
const server = new ApolloServer({
typeDefs,
resolvers,
introspection: true,
playground: {
settings: {
'request.credentials': 'include'
}
},
});
...