vercel/serve-handler

โœจ Configure base path via CLI option

jd-solanki opened this issue ยท 2 comments

Hi ๐Ÿ‘‹๐Ÿป

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.

+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.