ApolloServer GraphQL Playground not necessarily turned off in production
See original GitHub issueWhile
does turn off the playground
if in dev mode, because it relies on process.env.NODE_ENV
process.env.NODE_ENV !== 'production'
and this may not be set in Netlify, the GraphQL playground could be exposed.
export const createGraphQLHandler = ({
context,
getCurrentUser,
onException,
cors,
onHealthCheck,
...options
}: GraphQLHandlerOptions = {}) => {
const isDevEnv = process.env.NODE_ENV !== 'production'
const handler = new ApolloServer({
// Turn off playground, introspection and debug in production.
debug: isDevEnv,
introspection: isDevEnv,
playground: isDevEnv,
How to fix?
- make sure
process.env.NODE_ENV
is set? (edit: nope …) - be explicit and have
GRAPHQL_PLAYGROUND_ENABLED
env set only in dev and check that value for enabling the playground
Notes:
Issue at hand is the Netlify Build vs Runtime environment. You will have to explicitly set NODE_ENV
as a Netlify environment variable in their admin UI.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Why You Should Disable GraphQL Introspection In Production
In this post, we'll discuss why we believe you should disable GraphQL introspection in production, how to do it, and present a way...
Read more >In production with apollo-server-express 2.0.4 Playground is ...
This behavior can be over-ridden when you set the playground option in config. In 2.0.0, the graphql playground could be enabled when NODE_ENV= ......
Read more >Is there any option to disable playground when in production ...
In Apollo Server 3, Playground is disabled by default. In fact, they rolled their own "playground" because Playground has been retired.
Read more >GraphQL Overview - Keystone 6 Documentation
When NODE_ENV=production is not set, by default Keystone serves the GraphQL playground, an in-browser GraphQL IDE for debugging and exploring the API and ......
Read more >GraphQL Server Tutorial with Apollo Server and Express
In this chapter, you will implement server-side architecture using GraphQL and Apollo Server. The GraphQL query language is implemented as a ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
How about we change to
const isDevEnv = process.env.NODE_ENV === 'development'
?Actually this wouldn’t work yet, because NODE_ENV is
undefined
on localhost too. But I’ve fixed that in https://github.com/redwoodjs/redwood/pull/1653 So when that lands I can PR this fix too