Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite not working in v14.2.0 #200

Open
Matthematic opened this issue Jun 13, 2023 · 2 comments
Open

Rewrite not working in v14.2.0 #200

Matthematic opened this issue Jun 13, 2023 · 2 comments

Comments

@Matthematic
Copy link

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?

@JenLyndle
Copy link

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 ?

@Matthematic
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants