strapi
strapi copied to clipboard
[v4] 401 Unauthorized on admin panel settings -> Users&Permissions -> Roles when using prefix: ''
Bug report
Required System information
- Node.js version: v18.17.1
- NPM version: 9.6.7
- Strapi version: 4.25.13
- Database: PostgreSQL, empty new database
- Operating system: OSX, Alpine Linux
- Is your project Javascript or Typescript: JS
Describe the bug
While migrating from v3 to v4, I got stuck with the Users&Permissions plugin, trying to edit some role access. The strange thing is that I can access other sections in the admin panel, like settings -> Users&Permissions -> Providers,
but when I try Roles, it gives a 401 error and logs me out. Thanks to this forum post I found the error in the source code:
https://forum.strapi.io/t/401-when-accessing-content-type-builder-media-library-settings-user-permissions-plugin-roles/20115
It occurs in the verify(token)
function on @strapi/plugin-users-permissions/server/services/jwt.js
It seems this check should not happen at all, since it's not triggered on other sections, or when removing the prefix: ''
option.
Due to compatibility with existing project on v3, I need to remove the hardcoded prefix. Please help ?
Steps to reproduce the behavior
- Remove the /api prefix for API endpoints on
config/api.js
file, like so:
module.exports = {
rest: {
// remove the `/api` prefix
prefix: '',
defaultLimit: 25,
maxLimit: 100,
withCount: true,
},
};
- Run Strapi like it's hot
- Login as admin
- Go to Settings -> Users&Permissions -> Roles
Expected behavior
Should show the Roles page to change permissions