Is it possible to customize the /api prefix for Strapi API routes? In case it’s relevant, I installed Strapi using the command outlined in the Quick Start Guide: npx create-strapi-app@latest my-project --quickstart
My use case is that my server is already on a subdomain like api.example.com, so the /api path is not necessary. Ideally, I’d like to remove it, but renaming could work also.
Thank you, this does work. You are also correct that / doesn’t work, even if combined with prefix at the route level (so, for example, it does not seem possible to have some routes with /prefix1 and others with /prefix2.
Yeah - it’s a regression and if other applications depended on querying against the naked domain, those will break unless updated (which increases the migration complexity considerably).
Did you receive any feedback from engineering on this?
Hi @CEB3895, @DMehaffy ,
Thanks.The solution to add the prefix works for the rest api. But my admin is breaking as its throwing an error for the i18n/locales api. I am using below config as I don’t need any prefix.
Thanks @DMehaffy. Anyways I only wanted to REST apis to work which doesn’t have /api prefix as I am migrating my code from V3 to V4. I have achieved it using custom middleware as all my REST endpoint has a header x-store-id
Is it really the case that /api cannot be removed in Strapi v4? I’ve been searching for any way, but didn’t find yet. It really looks redundant in case of such URLs like api.example.com.