I would like to prefix all my strapi endpoints, but I receive a 405 error on the /admin/register-admin endpoint
I have generated a brand new strapi project using
npx create-strapi-app@latest my-project --quickstart
I have added /strapi-v4
to my config/server.js, as I would like to prefix all my endpoints with this.
server.js file
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
app: {
keys: env.array('APP_KEYS'),
},
url: '/strapi-v4',
webhooks: {
populateRelations: env.bool('WEBHOOKS_POPULATE_RELATIONS', false),
},
});
when I run strapi for the first time with yarn start
and try create an admin user, I receive a 405 error
why is this?
That's not a strapi issue. url
aren't supposed to work like that:
Public url of the server. Required for many different features (ex: reset password, third login providers etc.). Also enables proxy support such as Apache or Nginx, example: https://mywebsite.com/api. The url can be relative, if so, it is used with http://${host}:${port} as the base url. An absolute url is however recommended.
It needs an absolute url
and reason for that it should reflect reverse proxy configuration for stuff like redirects
work
e.g. https://example.com/strapi
in there will result https://example.com/strapi/api
.
You would not be able to resolve above to https://example.com/api
, you can check yarn strapi routes:list
to see amount of routes you gonna need to resolve.