-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin endpoint returns error 403 when using API token #7
Comments
Hey @nimajneb, This is somewhat by design. Every endpoint, wheter it comes from a plugin, or a core API is by default protected. If you’re using the users-permissions plugin from @strapi you can alter the public role and grant them permission specifically for this endpoint. Then anybody with an internet connection can make a request to the endpoint. Is this what you’re looking for? |
Hey @boazpoolman, No, I would like to keep this endpoint protected. What's unexpected for me is that even with a valid read API token it responds with said 403, while the autogenerated routes do work properly (using the same token). Interestingly enough, if I provide an invalid token, the url-alias route responds with HTTP 401 (message is: |
Aha got it. I haven’t used Strapi with the API tokens myself just yet. I’ll play around with it. probably some config I need to set to make it work 🙂 |
@nimajneb I added the change that worked for your custom endpoints in the plugin:
Tested it out and it seemed to work for me.
|
@boazpoolman It works like a charm now. Thanks! :) This is the same solution I described above (by just hacking the plugin source in node_modules). I was just not sure if it's the proper way of doing it, because I couldn't find this in the strapi documentation. |
Honestly, I'm not sure if this is the correct way of doing it myself aswel. But ah wel. If it works it works huh 🤷 |
This was released with version |
As mentioned in #17, by adding the I've rolled back the change and released that in |
Bug report
Describe the bug
In an out-of-the-box installation of Strapi 4.3.2 and a clean install of the URL alias plugin, using the provided endpoint
<API-URL>/url-alias/get?path=/custom/path
returns a HTTP 403 error:I'm not sure if this should be considered a bug, feature request or just a documentation issue, so feel free to move this issue.
Steps to reproduce the behavior
<API-URL>/url-alias/get?path=/custom/path
Expected behavior
The actual entity should be returned.
Code snippets
I ran into the same issue when creating custom routes of my own, and as far as I've been able to research, it seems to have something to do with the API being protected by default. Generating a "read" API token makes the auto-generated routes return content, but it is not sufficient to make the routes of the URL alias plugin work.
What helped for my custom routes was to add an auth section to the routes config like so:
I can't do that for the plugin of course, and since this does not seem to be documented by Strapi, I don't know if this is really the correct way of handling it.
System
The text was updated successfully, but these errors were encountered: