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

@ory/next: use of headers() leads to warnings/errors #334

Open
3 of 5 tasks
jonas-jonas opened this issue Jan 20, 2025 · 0 comments
Open
3 of 5 tasks

@ory/next: use of headers() leads to warnings/errors #334

jonas-jonas opened this issue Jan 20, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@jonas-jonas
Copy link
Member

Preflight checklist

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

@jonas-jonas jonas-jonas added the bug Something isn't working label Jan 20, 2025
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

No branches or pull requests

1 participant