admin管理员组

文章数量:1393920

My backend server has following routing:

/myapp/api/ - for api calls

/myapp/static/ - for assets

Anything that doesn't match this two must return index.html, or 404 if file requested (to allow SPA to handle url's path). So vite proxy server must handle all requests under /myapp, but requests which are NOT started from /myapp/static/ must be redirected to backend server. All generated urls to assets (hrefs, imports, etc..) must have /myapp/static/ prefix.

So here is the issue: If I set base: '/myapp/static/' option in vite.config, vite stops serving /myapp/...whatever... requests

I could set only base: '/myapp/' and then configure proxy to redirect all requests except /myapp/static to backend server. But in this case assets urls lack of /static/ segment. So how to have /myapp/static prefix for all assets paths, while still serving just /myapp/...whatever... requests? I didn't found simple way to differ this two.

Or maybe my whole setup approach is just incorrect?

本文标签: single page applicationUrls to assets should be subpath of base path of vite proxyStack Overflow