Skip to content

Conversation

sommeeeer
Copy link
Contributor

@sommeeeer sommeeeer commented Sep 3, 2025

When you have a rewrite in middleware like this:

return NextResponse.rewrite(u, {
  status: 403,
});

The rewrite status code is not propogated to the cache interceptor's responses when you have an external middleware.

We can also safely remove the x-next-cache-tags header on the response.

I did update some tests that were flakey aswell. We need to register the event listener before the navigation.

Copy link

changeset-bot bot commented Sep 3, 2025

🦋 Changeset detected

Latest commit: 51e86d7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@opennextjs/aws Patch
app-pages-router Patch
app-router Patch

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

pkg-pr-new bot commented Sep 3, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/@opennextjs/aws@974

commit: 51e86d7

@sommeeeer sommeeeer force-pushed the fix-rewrite-status-code-external-mw branch from 0045dca to bf40d1d Compare September 7, 2025 19:18
@sommeeeer sommeeeer requested a review from conico974 September 7, 2025 19:26
@sommeeeer sommeeeer marked this pull request as draft September 7, 2025 19:30
…cache interceptor

changeset

fix test

fix test

refactor deletion of cache tags header

review

update test
@sommeeeer sommeeeer force-pushed the fix-rewrite-status-code-external-mw branch from bf40d1d to 51e86d7 Compare September 7, 2025 19:31
@sommeeeer sommeeeer marked this pull request as ready for review September 7, 2025 19:51
@sommeeeer
Copy link
Contributor Author

Alright, thanks for the review Nico! This one should be ready to go now :)

@conico974 conico974 merged commit e8f0f5d into opennextjs:main Sep 21, 2025
3 checks passed
@github-actions github-actions bot mentioned this pull request Sep 21, 2025
@sommeeeer sommeeeer deleted the fix-rewrite-status-code-external-mw branch September 21, 2025 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants