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

[🐛 Bug]: Failed to read header in page / layout after setting it in the middleware #797

Closed
1 task
clmnin opened this issue Jun 3, 2024 · 1 comment · Fixed by #811
Closed
1 task
Labels
bug Something isn't working

Comments

@clmnin
Copy link

clmnin commented Jun 3, 2024

next-on-pages environment related information

System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.5.0: Wed May 1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020
CPU: (10) arm64 Apple M2 Pro
Memory: 16 GB
Shell: /bin/zsh
Package Manager Used: npm (10.5.0)

Relevant Packages:
@cloudflare/next-on-pages: 1.11.3
vercel: 34.2.4
next: 14.1.0

Description

Cloudflare next-on-pages fails to read header in next js pages/layout after setting it in the middleware.

Reproduction

I have created a minimal reproducible example in this repo - clmnin/cf-middleware-set-header

How to set it up

git clone https://github.com/clmnin/cf-middleware-set-header.git
cd cf-middleware-set-header
npm i

Run NextJS Dev to see what are the expected outputs

npm run dev
# console log "token-value" for the middleware, page and layout
# ▲ Next.js 14.1.0
# - Local:        http://localhost:3000
# 1. middleware: token-value
# 2. page: token-value
# 3. layout: token-value

This is the expected output for a next js app. The page and layout routes get the response passed by the middleware.

Run Cloudflare pages preview using wrangler

npm run preview
# fails to console log "token-value" for the middleware, page and layout
# [wrangler:inf] Ready on http://localhost:8788
# 1. middleware: token-value
# 2. page: null
# 3. layout: null

Pages Deployment Method

None

Pages Deployment ID

No response

Additional Information

No response

Would you like to help?

  • Would you like to help fixing this bug?
@dario-piotrowicz
Copy link
Member

Hi @clmnin thanks a bunch for the issue 🙂
(and thanks so very much for the minimal reproduction! that's been extremely helpful!!! ❤️)

Sorry it took me a while to get to it 🙇

#811 that should fix it, if you want please feel free to try the PR's prerelease and let me know if that works for you 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants