vercel/serve-handler

Can't figure out to configure to serve a virtual path

zshlomyz opened this issue · 4 comments

Hi,
I would like the server listen to a virtual path / base-path like this - localhost:/.
I used the rewrite property but I didnt found a way that serve the index.html file when accesing without postfix while serving the other files.
My configuration:
{ "rewrites": [ { "source": "/virtual-path", "destination": "/index.html" }, { "source": "/virtual-path/:rest", "destination": "/:rest" } ] }

Please help,
Thanks

Anybody familiar with this? I cannot figure it out..

@chasen-bettinger You can use the fragments feature like this:

{
  "rewrites": [
    {
      "source": "path/you/want/:asset",
      "destination": ":asset"
    }
  ] 
}

I am struggling with this same issue, and I've not found the correct set of google terms to answer this :-)

I want to serve a folder "my_site" but I want to prefix it so that the url would be http://some_prefix/some_folder/

I tried this

rewrites: [{source: "my_prefix/:path", destination: "/:path"}]

and then ran serve ./my_html_files which has my static content in it

It almost works

If i navigate to http://localhost/my_prefix/some_folder I see directly listing, but if i try to go to index.html i get nothing :-[

What do i need to do to serve a folder, and have it appear to be under some other folder on a virtual path?

I tried this based on a thread above and it does not seem to work either:

{
  "rewrites": [{ "source": "some_virtual_prefix/:path+", "destination": "/:path(.+)" }]
}