Jortega
Jortega

Reputation: 61

Apollo-server hide graphql ui in production

I've been searching for an explanation of this. The question is kind of "basic" so I was hopping to find the solution quickly, but I haven't.

I want to hide the graphical ui in production server so anyone can't see my queries, but I can't. I don't have problems to figure it out how to have different environment variables in local and in production. I searched in the documentation but I can't find the way.

Thanks in advance!

Upvotes: 1

Views: 2533

Answers (3)

markyph
markyph

Reputation: 154

Anyone using Apollo Server 4 - the following plugin needs to applied: ApolloServerPluginLandingPageDisabled() - as playground has been removed from the config.

Upvotes: 1

Leandro Raveli
Leandro Raveli

Reputation: 11

Perhaps you are not setting the NODE_ENV=production.

In development, Apollo Server enables GraphQL Playground on the same URL as the GraphQL server itself (e.g. http://localhost:4000/graphql) and automatically serves the GUI to web browsers. When NODE_ENV is set to production, GraphQL Playground (as well as introspection) is disabled as a production best-practice.

Upvotes: 1

Sumeet Kumar Yadav
Sumeet Kumar Yadav

Reputation: 12965

To disable UI you can configure using playground: false

https://www.apollographql.com/docs/apollo-server/testing/graphql-playground/

const server = new ApolloServer({
  schema, 
  introspection: false,
  playground: false,
});

Upvotes: 2

Related Questions