-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Unable to return custom pages with a 404 status code #12541
Comments
Just return a new return new Response("not found", {
status: 404
}) Plus, You can't return a 404 with the content you want. Use the middleware in that case, where you can catch the response using |
@ematipico thanks for your answer. I have a few questions related to it:
|
404 is a special status code in Astro. Returning 404 will render the special route
You can do that using
Sorry, I did not know that I would ask you to not reply to this issue anymore, if you don't mind. We use this issue tracker for bugs, and not support questions. If you still have questions, feel free to open a thread in the |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I'm unable to return a page with a 404 status having custom content per URL. Whenever I set the status code to 404 either Astro's default 404 page or my custom 404 page is returned but never the content I intend to be returned. I cannot find a way to disable that behavior. When I return any other status code, e.g. a
410
, things work as expected.Use case:
In an online shop, when a product is no longer offered, I want to return a 404 status code under the product's URL for SEO reasons while still providing the user with custom content, i.e. the search results of similar articles.
Example:
GET https://www.my-shop.com/products/sneaker-no-1
I want this URL to return a 404 Status with custom content containing search results for similar products.
Everything works if I returned a
410 Gone
response instead, but I want to return a 404 because of SEO.What's the expected result?
I expect to be able to to return customized 404 pages.
Link to Minimal Reproducible Example
https://idx.google.com/just-the-basics-6947654
Participation
The text was updated successfully, but these errors were encountered: