vercel / serve-handler

The foundation of `serve`

Home Page:https://npmjs.com/serve-handler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rewrite not working in v14.2.0

Matthematic opened this issue · comments

Hello, I am using create-react-app to generate my build folder for my SPA and I want to serve a single, standalone html file called health.html that is also in the public folder, like so:
image

A request to localhost:3000/health should serve health.html, and any other requests should serve index.html. For some reason I cannot get this to work at all. From the docs, the following contents of serve.json seems like it is correct, but all requests to /health still redirect to index.html.

{
    "rewrites": [
      { "source": "/health", "destination": "/health.html" }
    ]
}

For reference, I am using this command:

serve -s build

What am I doing wrong?

I am having a similar issue. I have the serve.json in dist folder and serving it and my rewrite rules do not seem to work. did you find a solution @Matthematic ?

I am having a similar issue. I have the serve.json in dist folder and serving it and my rewrite rules do not seem to work. did you find a solution @Matthematic ?

This was nearly a year ago and the contract for that job was fulfilled so I no longer have access to the code, but from memory I believe I switched the project over to vite instead of create-react-app since the latter is no longer maintained. This can be done easily with vite plugins.