Deploy strapi + SPA app

Hey there,

I’m deploying a web app based on Strapi for the backend + VueJS for the frontend so I’d like to serve the SPA app from Strapi server, my idea is to build the Vue app and move built assets into Strapi public/ folder, but to make this working I need to change Strapi router prefix, so the REST API would be served at /api, then I’ll create some rule to rewrite any URL but static files and /api to /index.html

Now I searched a lot but I couldn’t find a clear answer or docs on how to set a global prefix for the API (I don’t care that much of the admin portal for now and it could stay at /admin).
I tried to set server.url, the config is applied as the CLI prints:

Welcome back!
To manage your project �, go to the administration panel at:

To access the server :zap:, go to:

but I can’t access the API and also the admin is broken as it tries to load static assets from /admin. I also tried to set middleware.router.prefix but it seems ignored

Do you have any idea? how do you typically deploy strapi + spa?

This is not something that we support and don’t currently have plans to. Strapi itself is headless, meaning it’s geared and built to ran on it’s own and not integrated into a frontend “channel” (as that would be a decoupled CMS). The Koa router can get very complex when it comes serving both a frontend and backend and our current implementation with the Admin panel is to handle this via a subfolder (IE /admin) with our landing page just being very simple and service static assets on the root (IE /index.html)

I would very strongly suggest you avoid joining the two within Strapi and handle this at a proxy level, we already have some guides for that here:

by trying to mix Vue and Strapi and serve them both from the same running process you are going to have the Vue Router and the Koa Router constantly fighting for control.

Thanks for your response!

What are your views on this repo, will this configuration will help ?