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

fix(routing): middleware in dev #12420

Merged
merged 3 commits into from
Nov 13, 2024
Merged

fix(routing): middleware in dev #12420

merged 3 commits into from
Nov 13, 2024

Conversation

ematipico
Copy link
Member

Changes

Closes #12391
Closes PLT-2627

The middleware is called even when a user doesn't have a route that doesn't match an existing FS route. Users can return a Response that isn't a 404.

The dev server didn't know that, so this PR fixes it.

To understand this use case, I decoded to add a tiny logic to our no-op middleware, which is used only when the user doesn't have a middleware. The no-op middleware adds an arbitrary header. If header isn't present, it means that the user have their own middleware, so we need to return any status returned by the .render function.

Testing

Added two new test cases

Docs

N/A

Copy link

changeset-bot bot commented Nov 12, 2024

🦋 Changeset detected

Latest commit: 1fd5238

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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Nov 12, 2024
Copy link

codspeed-hq bot commented Nov 12, 2024

CodSpeed Performance Report

Merging #12420 will not alter performance

Comparing fix/middleware-dev (1fd5238) with main (e723e9e)

Summary

✅ 1 untouched benchmarks

@ematipico ematipico merged commit acac0af into main Nov 13, 2024
15 checks passed
@ematipico ematipico deleted the fix/middleware-dev branch November 13, 2024 13:34
@astrobot-houston astrobot-houston mentioned this pull request Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Status code in response set by middleware is not respected
2 participants