【发布时间】:2022-11-11 23:46:41
【问题描述】:
我想让我的 Graphql API 更安全,我正在寻找一种方法来禁用 Nestjs for Public 中的 Graphql Introspection 或排除某些私有 API 但无法在 Nestjs 文档中找到任何参考的方法,
我有 AuthGuards 设置,但它们不会起到阻止模式访问的目的。
【问题讨论】:
标签: security graphql nestjs production
我想让我的 Graphql API 更安全,我正在寻找一种方法来禁用 Nestjs for Public 中的 Graphql Introspection 或排除某些私有 API 但无法在 Nestjs 文档中找到任何参考的方法,
我有 AuthGuards 设置,但它们不会起到阻止模式访问的目的。
【问题讨论】:
标签: security graphql nestjs production
如果您使用的是 Apollo,答案就在那里in the docs。
const server = new ApolloServer({
typeDefs,
resolvers,
introspection: process.env.NODE_ENV !== 'production'
});
这会禁用生产中的自省。
如果您想始终禁用它(不推荐,因为它更难开发):
introspection: false
【讨论】: