undefined reading headers using next/headers && appDir
Verify canary release
- [X] I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro Binaries: Node: 18.8.0 npm: N/A Yarn: N/A pnpm: N/A Relevant packages: next: 13.0.3-canary.0 eslint-config-next: 13.0.0 react: 18.2.0 react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome 107
How are you deploying your application? (if relevant)
npm run dev
Describe the Bug
When tries get headers from page using appDir, i get Error: Cannot read properties of undefined (reading 'headers'),
Expected Behavior
Get request headers
Link to reproduction
https://stackblitz.com/edit/vercel-next-js-ee8sib?file=app%2Fpage.tsx
To Reproduce
Just import headers then call function on function body
import { headers } from 'next/headers' export default async function Home() { const cookie = headers().get('cookie'); }
Can you reproduce this locally as well, or only on StackBlitz? It works fine on my local machine but reproduces on your link. :thinking:
Can you reproduce this locally as well, or only on StackBlitz? It works fine on my local machine but reproduces on your link. 🤔
Also in my machine, i've tried with most recent versions (v13.0.6 and 13.0.7-canary.1) and problem continues
The "cookies()" function of next/headers also has the same problem, not being an alternative.
Fixed uninstalling node 18 and reinstalling v19
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.