[英]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!提前致谢!
To disable UI you can configure using playground: false
要禁用 UI,您可以使用
playground: false
https://www.apollographql.com/docs/apollo-server/testing/graphql-playground/ https://www.apollographql.com/docs/apollo-server/testing/graphql-playground/
const server = new ApolloServer({
schema,
introspection: false,
playground: false,
});
Perhaps you are not setting the NODE_ENV=production.也许您没有设置 NODE_ENV=production。
In development, Apollo Server enables GraphQL Playground on the same URL as the GraphQL server itself (eg http://localhost:4000/graphql) and automatically serves the GUI to web browsers.在开发中,Apollo 服务器在与 GraphQL 服务器本身相同的 URL 上启用 GraphQL Playground(例如 http://localhost:4000/graphql)并自动为 web 浏览器提供 GUI。 When NODE_ENV is set to production, GraphQL Playground (as well as introspection) is disabled as a production best-practice.
当 NODE_ENV 设置为生产时,GraphQL 游乐场(以及内省)被禁用作为生产最佳实践。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.