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

Sending 404 status code when the routes don't match #799

Open
sidvenu opened this issue Aug 21, 2021 · 2 comments
Open

Sending 404 status code when the routes don't match #799

sidvenu opened this issue Aug 21, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@sidvenu
Copy link

sidvenu commented Aug 21, 2021

Is your feature request related to a problem? Please describe.
I observe router sends 200 status code when no routes match.

Describe the solution you'd like
Allow us to send status codes based on the path.

Describe alternatives you've considered
Sending 404s in the server (apache/nginx) layer, but that gets complicated as we have a lot of routes.

Additional context
React Router has the ability to send status codes: https://stackoverflow.com/questions/36052604/how-to-let-react-router-respond-with-404-status-code.

I've also opened a similar issue in preactjs/preact-router: preactjs/preact-router#402.

@sidvenu sidvenu added the enhancement New feature or request label Aug 21, 2021
@JoviDeCroock
Copy link
Member

What are you using as a serving mechanism as from client-side code it's not possible to set a server-side response code, as the stackoverflow you linked alludes to, you set this property to catch this in your serving layer.

@developit
Copy link
Member

I left a solution for the render-to-string piece over on your preact-router issue. As @JoviDeCroock mentioned, WMR doesn't provide an SSR runtime (currently), so status codes are entirely up to your server (apache/nginx) to determine.

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

No branches or pull requests

3 participants