-
-
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
refactor: remove endpoint handling infra #9775
Conversation
🦋 Changeset detectedLatest commit: c1c91fa The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactors should not have changelogs, since users don't need to know about these refactors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went back and forth on this. We can't say ever say for sure, there won't be regression and the changelog comes in handy. At the end, it's just another entry in the changelog.
}); | ||
} | ||
if (REROUTABLE_STATUS_CODES.has(response.status) && response.headers.get("X-Astro-Reroute") !== "no") { | ||
return this.#renderError(request, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we remove the routeData.type === 'page' || routeData.type === 'redirect'
check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was there to carve out endpoints from the rerouting behavior. That does not happen anymore.
const response = await handler.call(mod, context); | ||
// Endpoints explicitly returning 404 or 500 response status should | ||
// NOT be subject to rerouting to 404.astro or 500.astro. | ||
response.headers.set("X-Astro-Reroute", "no"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might as well move X-Astro-Reroute
to a const
at this point, to avoid possible typos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea. I can do that in a future PR.
Changes
Pipeline
implemented once for each environment.callEndpoint
created a response with a special header. The endpoint handler recognises the special header and throws a special error. ThenApp
recognises the special error and finally performs the rerouting.callEndpoint
creates a response with a special header ("X-Astro-Reroute=no"), and App recognises it to perform the rerouting directly.Testing
Does not affect behavior. Existing tests should pass.
Docs
Does not affect usage.