简体   繁体   English

Strapi register method not allowed 405 in v4 似乎 url 不正确

[英]Strapi register method not allowed 405 in v4 seems url is incorrect

quite puzzled with a Strapi question.对 Strapi 的问题感到非常困惑。 Working with v4 and hooking up a registration functionality.使用 v4 并连接注册功能。 Invoke code is below.调用代码如下。 All other things are good ie function variables being submitted, etc. But when I call strapi.register I get a 405 All my roles/permissions are good:所有其他事情都很好,即 function 变量正在提交等。但是当我调用strapi.register时,我得到一个 405 我所有的角色/权限都很好:

// make request to register user with strapi
const response = await strapi.register(username, email, password);

Result: POST http://localhost:1337/auth/local/register 405 (Method Not Allowed)结果: POST http://localhost:1337/auth/local/register 405 (Method Not Allowed)

When I look in the Strapi admin in the User roles and permissions, I see in the box where the register options is that the target url is: /api/auth/local/register !!!当我在用户角色和权限中查看 Strapi 管理员时,我在框中看到register选项是目标 url 是: /api/auth/local/register !!!

What gives?是什么赋予了? I read that you may can do something in /config/api.js or similar, or maybe use a proxy in package.json .我读到您可以在 /config/api.js 或类似内容中执行某些操作,或者在package.json中使用代理。 Can't resolve why this url is different?无法解决为什么这个 url 不同? Is it a bug?它是一个错误吗? How would you make this work.你将如何进行这项工作。 I am specultating that I need to add /api to the request somewhere.我推测我需要将/api添加到某处的请求中。 But don't know where.但不知道在哪里。 Thanks everyone!感谢大家!

You're missing the api/ part.您缺少api/部分。 You should change your path for:你应该改变你的路径:

http://localhost:1337/api/auth/local/register

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM