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

-s option ignore existing file

Open ambroiseRabier opened this issue 4 years ago • 3 comments

Files:

  1. build/index.html
  2. build/subdir/index.html

With serve -s build:

  • 1 work as expected. localhost:5000
  • 2 is being ignored, localhost:5000/subdir and localhost:5000/subdir/index.html give 404 or redirect to root (don't remember which one).

With server build:

  • 1 work as expected. localhost:5000
  • 2 work as expected. localhost:5000/subdir

I would have expected localhost:5000/subdir with serve -s build to server build/subdir/index.html, and not build/index.html (or 404) (I think it was redirect).

--help show description:

-s, --single                        Rewrite all not-found requests to `index.html`

But current behavior seem to be "rewrite all requests to /index.html".

ambroiseRabier avatar Jul 19 '20 20:07 ambroiseRabier

Also had this issue, it seems serve-handler by default redirect /build/subdir/index.html to /build/subdir, which is called 'cleanUrls' The temporary solution is to disable 'cleanUrls' by adding a serve.json:

{
    "cleanUrls": false
}

buhichan avatar Feb 22 '21 08:02 buhichan

shameless self-promotion alert:
this feature is fixed in my @warren-bank/serve fork of serve

warren-bank avatar Feb 16 '22 01:02 warren-bank

@buhichan where do I place the serve.json. Screenshot 2024-03-06 at 11 24 14 AM Am using serve to serve dist and the serve.json doesn't seem to work. The doc says to place the serve.json in public folder but am a bit confused about the placement. Any pointers will help, thanks!

JenLyndle avatar Mar 06 '24 19:03 JenLyndle