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

Cloudflare context is not avaiable in middleware on 404 route #12821

Closed
1 task
TorbjornHoltmon opened this issue Dec 23, 2024 · 1 comment · Fixed by #12935
Closed
1 task

Cloudflare context is not avaiable in middleware on 404 route #12821

TorbjornHoltmon opened this issue Dec 23, 2024 · 1 comment · Fixed by #12935
Labels
needs triage Issue needs to be triaged

Comments

@TorbjornHoltmon
Copy link
Contributor

TorbjornHoltmon commented Dec 23, 2024

Astro Info

Astro                    v5.1.1
Node                     v22.3.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When in development, when returning a 404 response on an Astro page, the Cloudflare context is not available inside middleware.

It works fine when deployed to Cloudflare.

I know this is an adapter issue, but I have experienced similar issues in the past ( #10421 ) and it might be related to how 404 pages ( 404 rewrites? ) are handled internally in Astro.

The repro is not stackblitz because I am not sure if the Cloudflare proxy even works there.

I also created an issue on the adapter repo ( withastro/adapters#492 )

What's the expected result?

The cloudflare context should be available in middleware on 404 pages

Link to Minimal Reproducible Example

https://github.com/TorbjornHoltmon/missing-cloudflare-context-repro

Participation

  • I am willing to submit a pull request for this issue.
@AirBorne04
Copy link
Contributor

Hi @TorbjornHoltmon

i have identified the source of the missing context on rendering the 404 on the second pass and have created a PR to address it.

@AirBorne04 AirBorne04 linked a pull request Jan 8, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants