elements
elements copied to clipboard
@ory/next: use of headers() leads to warnings/errors
Preflight checklist
- [x] I could not find a solution in the existing issues, docs, nor discussions.
- [x] I agree to follow this project's Code of Conduct.
- [x] I have read and am following this repository's Contribution Guidelines.
- [ ] I have joined the Ory Community Slack.
- [ ] I am signed up to the Ory Security Patch Newsletter.
Ory Network Project
No response
Describe the bug
It seems that using await here may make it compatible with Next.js v15. Reference: https://nextjs.org/docs/messages/sync-dynamic-apis
export function filterRequestHeaders(
forwardAdditionalHeaders?: string[],
): Headers {
const filteredHeaders = new Headers()
headers().forEach((value, key) => {
const isValid =
defaultForwardedHeaders.includes(key) ||
(forwardAdditionalHeaders ?? []).includes(key)
if (isValid) filteredHeaders.set(key, value)
})
return filteredHeaders
}
Error log:
[Error: Route "/api/.ory/[...paths]" used headers().forEach(...). headers() should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis]
Reproducing the bug
Relevant log output
Relevant configuration
Version
master
On which operating system are you observing this issue?
None
In which environment are you deploying?
None
Additional Context
No response