-
-
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
Rewriting doesn't use HTTP status code from rewritten response #11306
Comments
@vchirikov do you experience the same issue with |
Yes, btw the repro uses |
To be clear, the issue isn't about |
That wasn't clear from your "expectation" section. Can you be more clear, please? For example why Also, could you reduce the branching of the middleware in your repro? It's not very clear where's the issue. |
done in https://github.com/vchirikov/astro_issue_02/tree/issue-11306
As a developer I expect that successfully rewritten page should return status 200 instead of 404: |
You haven't told me why though, because in this case you're intentionally rewriting with special route 404, which always returns a status code 404. Why should it return a 200? IMHO, it should not. |
I rewrite all routes to I rewrite to an existing page, this page's Again rewriting correctly renders upd: oh, I think I get your point, I rewrite un-existed page and this is a special 404 route which always returns 404, but:
Example where it is useful: I want to rewrite |
@ematipico the issue is not fixed in 4.11.1 repro: https://github.com/vchirikov/astro_issue_02/tree/issue-11306 npm run dev
# expected status is 200
curl -I -X GET http://localhost:4321/foo |
@ematipico Apologies, but I don't believe this is fixed in 4.11.4 or 4.11.5. The repro above still returns 404 on both versions. I also noted that the repro and your fix uses |
@FugiTech the fix I applied isn't related to i18n, however that's how the user found the bug and that's how I tested the fix. Please open a new issue with a new reproduction and we will try to fix your issue too. |
@ematipico the issue is still here in p.s. repro the same - https://github.com/vchirikov/astro_issue_02 |
@ematipico reopen please |
@ematipico There are definitely still issues with this. I don't have time at this exact moment to create a reproduction, but I have a super simple middleware that just intercepts some paths to return responses, otherwise passing the requests through: export const onRequest: MiddlewareHandler = (context, next) => {
const headers = {"Content-Type": "text/html"};
return new Response(
`<html>
<head>
</head>
<body>
<p>Some text</p>
</body>
</html>`,
{ headers, status: 200 },
);
}; Despite the I will try to create a standalone reproduction this evening. |
I was on vacation. I will look into it. |
@ematipico I've updated the repro to
|
Please open a new issue, the original one is fixed :) |
Astro Info
Describe the Bug
If we rewrite from non-existed page we always get 404 status even if middleware rewrite to the valid page.
Looks like the response object from rewriting isn't used. This is the repro:
we should get http status 200 (because we rewrite to the /about page), but we see 404.
p.s. The issue was originally described here, this is separate issue for the bug with repro.
p.s. looks similar to the cookie issue (fixed by @ascorbic )
What's the expected result?
rewriting should use status code from rewritten page pipeline.
Link to Minimal Reproducible Example
https://github.com/vchirikov/astro_issue_02
The text was updated successfully, but these errors were encountered: