You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I generally publish my static site under some base path (not directly in root domain). Every time I make a build I have to create a dummy dirs to recreate the subpath environment and serve the site from root to test the site.
Is it possible to provide a base path via CLI option (serve --base "/myapp/") so each file is served like it is in myapp dir.
Thanks.
Reacted by Alex Ilyaev, Fergus Ruston, Ilya Iskra, kimsagro1, Yaroslav Lisovets, Yuri Sulyma and Nicolas Froidure
+1. I fiddled with this for an hour, only to realize that you cannot do this using just rewrites. You should be able to with path-to-regexp, but it seems that there is a replacement of * for (.*), the reason for which I do not understand.
Edit: I think it may be to allow minimatch to work as a fallback? It's all very strange.
It seems even if you specify /base/:path+, which does capture the subpath correctly, the rewritten URL will have its slashes escaped and so it will fail.
Activity
lericson commentedon May 30, 2024
+1. I fiddled with this for an hour, only to realize that you cannot do this using just rewrites. You should be able to with path-to-regexp, but it seems that there is a replacement of * for (.*), the reason for which I do not understand.
Edit: I think it may be to allow minimatch to work as a fallback? It's all very strange.
lericson commentedon May 30, 2024
It seems even if you specify
/base/:path+, which does capture the subpath correctly, the rewritten URL will have its slashes escaped and so it will fail.