Strapi:GraphQL突变无身份验证

发布于 2025-01-29 12:41:40 字数 89 浏览 2 评论 0原文

我为基于Strapi的简单电子购物商进行编程。我需要在没有任何JWT代币的情况下向公众打开自定义的“订单”突变,但我不知道如何。可以在Strapi中这样做吗?谢谢。

I program simple e-shop based on Strapi. I need to open my custom "order" mutation to public without any JWT token but I can't figure out how. Is it possible to do that in Strapi? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

红尘作伴 2025-02-05 12:41:40

在Strapi V4中,您可以这样做:

  1. 转到“设置”;
  2. 打开“角色”;
  3. 单击“公共”角色;
  4. 在“权限”部分中扩展所需模型;
  5. 指定要赋予权利的端点。

在您的情况下,它是“创建”。

In Strapi v4 you can do it like this:

  1. Go to "Settings";
  2. Open "Roles";
  3. Click on the "Public" role;
  4. Expand the desired model in the "Permissions" section;
  5. Specify which endpoints you want to give rights.

In your case it is "create".

撩动你心 2025-02-05 12:41:40

看看 https://docs.strapi。 io/developer-docs/最终/插件/graphql.html#扩展-the-schema

resolversConfig具有称为auth的属性,该属性如下:

auth:false到完全绕过授权系统并允许所有请求

请求

  resolversConfig: {
    'Mutation.updateAddress': {
      auth: false,
    },
  },

所有

Look at https://docs.strapi.io/developer-docs/latest/plugins/graphql.html#extending-the-schema:

resolversConfig has a property called auth which is like:

auth: false to fully bypass the authorization system and allow all requests

So for example you need to specify your mutation name:

  resolversConfig: {
    'Mutation.updateAddress': {
      auth: false,
    },
  },

Otherwise just override your resolver

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文