Open rakeshneelarapu opened 11 months ago
Any updates on this issue?
Edit by maintainers: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote π on the issue description or subscribe to the issue for updates. Thanks!
Any updates? I also have the same issue now.
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote π on the issue description or subscribe to the issue for updates. Thanks!
Currently facing the same issue. A workaround might be to use nextjs middleware
import { NextResponse } from 'next/server';
export function middleware(request: Request) {
const requestHeaders = new Headers(request.headers);
requestHeaders.set('my-url', request.url);
return NextResponse.next({
request: {
headers: requestHeaders,
},
});
}
Then you can do:
const myUrl = headersList.get('my-url');
At times, headers() returns no headers whatsoever. This problem isn't limited to just the referer header; I'm experiencing it with other headers like next-url as well.
Even using middleware hasn't resolved the issue; I'm consistently receiving empty headers in certain instances.
Any updates? I also have the same issue.
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote π on the issue description or subscribe to the issue for updates. Thanks!
can confirm this
Still experiencing this issue
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote π on the issue description or subscribe to the issue for updates. Thanks!
for me referals from twitter are null in the headers.get("referer") object
however i suspect it is because of twitters handling of outgoing links
Getting the referer header in Next.js layout returns null for subsequent requests/renders, is there a fix? @leerob
IΒ΄ve been able to reproduce this issue on my end too. Facing the same error.
having the same problem in Nextjs middleware, I get null all the time.
Same problem
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote π on the issue description or subscribe to the issue for updates. Thanks!
Is there any fix to this? I'm facing the same issue...
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote π on the issue description or subscribe to the issue for updates. Thanks!
I saw this before using :) Can say, saved some time. Thanks.
Link to the code that reproduces this issue
https://github.com/rakeshneelarapu/nextjs-headers
To Reproduce
Working Example
Not Working Example
Current vs. Expected behavior
Bug: Referer is coming as null when reading from the next/headers
Expected Behaviour: Referer should be fetched correctly when reading from the next/headers
Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router, Routing (next/router, next/navigation, next/link)
Additional context
Sometimes when we hot reload the server or make any changes in the component files, it works fine, but most of the times, we see this issue of null