Closed MO-Lewis closed 1 year ago
Hello and welcome!
Great plugin! This was extremely handy for people who didn't want Strapi V4's unnecessary data / attributes nesting system.
Thanks, I saw quite a few people unhappy with the current response structure and figured it would be a useful plugin. Turns out I was correct :)
However, whilst trying to modify the value of "prefix" in my plugin configuration, it seems that none of the changes I make actually affect the resolved prefix when I start the application.
The plugins prefix setting was not intended to be used for rerouting/modifying the API prefix. It was introduced at a time when i was not as familiar with the Strapi API and was used for determining if a request was from the admin or not.
At this point it is not being utilized by the plugin but is a breaking change to remove.
For context, I'm using AWS Cloudfront and a reverse proxy to host the frontend and backend under the same URL. Anything that's api/* defaults to the Strapi backend. This worked on V3, but upgrading to V4 has caused our endpoints to now become api/api/articles, which we expected.
On v4 you can set the API prefix to be top level like it was in v3 by setting the rest.prefix to /
in the api configuration. Any other prefix you may wish to use instead is also accepted of course.
Hope that helps! let me know if any further questions or clarification is needed.
Thank you so much! I didn't realize Strapi can now do this without the plugin. There are a couple of things to be clarified though.
Using just '/'
will mean that my Api would be reachable via localhost:3000//articles?populate=*
, with a couple slash. I don't want this, so I changed it to ''
.
This then caused the issue with the i18n plugin, which stopped me from accessing the admin panel, which has been reported here https://forum.strapi.io/t/customize-api-prefix-for-apis/13648 and here https://forum.strapi.io/t/customize-api-prefix-for-apis/13648/7.
Finally, I changed it to '/v1'
, and it's now routing how I want it to!
Just thought I'd add those 3 things in case anyone else stumbles upon this issue in the future :).
Thanks again!
Using just '/' will mean that my Api would be reachable via localhost:3000//articles?populate=*, with a couple slash. I don't want this, so I changed it to ''.
I had never done it myself so /
was somewhat of a guess :). Glad you figured it out and thanks for the update!
Hi there,
Great plugin! This was extremely handy for people who didn't want Strapi V4's unnecessary data / attributes nesting system.
However, whilst trying to modify the value of "prefix" in my plugin configuration, it seems that none of the changes I make actually affect the resolved prefix when I start the application.
Each time, I delete the
.cache
andbuild
folder, and run a cleanstrapi build
, nothing seems to make a difference.Here's my full
plugins.js
file, so you can see the other plugins I use:And here's all of my dependencies from
package.json
, so you can see what else I'm working with:Here's a couple of screenshots showing it not working as intended:
It would be fantastic if you could find / fix the issue that's going on here! I'll happily provide any other info you might need.
For context, I'm using AWS Cloudfront and a reverse proxy to host the frontend and backend under the same URL. Anything that's
api/*
defaults to the Strapi backend. This worked on V3, but upgrading to V4 has caused our endpoints to now becomeapi/api/articles
, which we expected.If I can't outright get rid of the second
/api/
, then I'll just rename it to/api/v1/*
, so it doesn't look as bad.Thanks in advance for any help / advice you can provide!