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

SPA app HTTP responses are always 200 (never 404) #213

Open
oudeismetis opened this issue Aug 15, 2023 · 0 comments
Open

SPA app HTTP responses are always 200 (never 404) #213

oudeismetis opened this issue Aug 15, 2023 · 0 comments
Labels

Comments

@oudeismetis
Copy link
Member

Vue (and other SPAs) will always return an HTTP 200 response, even on a page not found 404.
This is because HTTP responses happen at a lower level.

We could pass 404s to the server and let the server return a proper 404, but that would limit having a more advanced 404 page.

This was the issue with this PR: #212

There are some ideas out there on how to do this better:
https://stackoverflow.com/questions/54218371/how-to-get-a-404-response-in-vue-router
https://stackoverflow.com/questions/73098868/vuejs-real-seo-friendly-404-page-for-search-engines-like-google-msn

The original reason I tried to solve this was because of backend tests being written to test the API, checking that the response was 200 (which it always was) and not realizing that the test was failing because of a mis-typed URL.

One possible idea:
Create a pytest fixture, mock, and/or Cypress utility that intercepts calls, inspects the payload for an error, and then fails the test.

This is expected behavior so not technically a bug. But something that could be improved anyway.

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

No branches or pull requests

1 participant