serve-handler icon indicating copy to clipboard operation
serve-handler copied to clipboard

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

Open zshlomyz opened this issue 6 years ago • 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

zshlomyz avatar Dec 31 '19 08:12 zshlomyz

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

chasen-bettinger avatar Jun 23 '20 16:06 chasen-bettinger

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

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

Chili-Man avatar Jun 27 '20 01:06 Chili-Man

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?

whazlewo avatar Mar 28 '24 23:03 whazlewo

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

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

whazlewo avatar Mar 28 '24 23:03 whazlewo