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): skip middleware for external redirects #13133

Merged
merged 5 commits into from
Feb 4, 2025

Conversation

ematipico
Copy link
Member

Changes

Closes #13120

The fix is inside RenderContext, and now check if the route that we are about to render is an external redirect. If it is, we skip the whole middleware chain, and render the redirect straight away.

I checked with Matt and Florian, and they agree with the proposed solution.

Testing

I added a new test and fixture based on the reproduction provided.

Docs

N/A

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Feb 4, 2025
@ematipico ematipico force-pushed the fix/static-redirect branch from 94a9703 to ed3a753 Compare February 4, 2025 11:12
Copy link

changeset-bot bot commented Feb 4, 2025

🦋 Changeset detected

Latest commit: 7f005a7

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

Copy link
Member

@florian-lefebvre florian-lefebvre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs a changeset

@@ -64,6 +64,7 @@ export function createI18nMiddleware(
};

return async (context, next) => {
console.log('calling headers type');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('calling headers type');

packages/astro/src/core/routing/match.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, aside from the console.log

Copy link

codspeed-hq bot commented Feb 4, 2025

CodSpeed Performance Report

Merging #13133 will not alter performance

Comparing fix/static-redirect (b2f9e55) with main (d60c742)

Summary

✅ 6 untouched benchmarks

@ematipico ematipico merged commit e76aa83 into main Feb 4, 2025
17 checks passed
@ematipico ematipico deleted the fix/static-redirect branch February 4, 2025 12:36
@astrobot-houston astrobot-houston mentioned this pull request Feb 4, 2025
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.

External redirects break static build
3 participants