Skip to content

feat(nextjs): Add URL to tags of server components and generation functions issues #16500

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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

RulaKhaled
Copy link
Member

@RulaKhaled RulaKhaled commented Jun 6, 2025

Next.js’s uses an internal AsyncLocalStorage (ALS) to share minimal request context—it deliberately does not populate the full Request object or URL in ALS, so only headers (Referer, x-forwarded-host, x-forwarded-proto) are available at runtime in Server Components.

To still capture a usable URL for metadata we use a three-step best-effort fallback:

  1. Referer header
Use it as the fully qualified URL if present (note: this could be omitted by the browser).
  2. Proxy headers + route
Reconstruct protocol://host from x-forwarded-proto / x-forwarded-host (or host), then append the normalized component route with substituted [param] values. Query strings and fragments are TBD as query params fetched from args are always undefined for some reason, this needs investigation
  3. Span fallback
As a last resort, use the parent span’s http.target attribute (which contains the path and query) from the root HTTP span.
Screenshot 2025-06-02 at 4 04 31 PM

@RulaKhaled RulaKhaled changed the title [WIP] feat(nextjs): Add URL to tags of server components and generation functions issues feat(nextjs): Add URL to tags of server components and generation functions issues Jun 10, 2025
@RulaKhaled RulaKhaled marked this pull request as ready for review June 10, 2025 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant