javascript - Strapi register method not allowed 405 in v4 seems url is incorrect - Stack Overflow

quite puzzled with a Strapi question.Working with v4 and hooking up a registration functionality.In

quite puzzled with a Strapi question. Working with v4 and hooking up a registration functionality. Invoke code is below. All other things are good i.e. function variables being submitted, etc. But when I call strapi.register I get a 405 All my roles/permissions are good:

// 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)

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 !!!

What gives? I read that you may can do something in /config/api.js or similar, or maybe use a proxy in package.json. Can't resolve why this url is different? Is it a bug? How would you make this work. I am specultating that I need to add /api to the request somewhere. But don't know where. Thanks everyone!

quite puzzled with a Strapi question. Working with v4 and hooking up a registration functionality. Invoke code is below. All other things are good i.e. function variables being submitted, etc. But when I call strapi.register I get a 405 All my roles/permissions are good:

// 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)

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 !!!

What gives? I read that you may can do something in /config/api.js or similar, or maybe use a proxy in package.json. Can't resolve why this url is different? Is it a bug? How would you make this work. I am specultating that I need to add /api to the request somewhere. But don't know where. Thanks everyone!

Share Improve this question asked Jan 21, 2022 at 4:28 RachelRachel 7273 gold badges14 silver badges22 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

You're missing the api/ part. You should change your path for :

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745355626a4624098.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信