NextRequest.nextUrl.hash always returns an empty string in middleware: Is this the intended behavior? #49794
Replies: 2 comments 2 replies
-
And that's the end of it. The root of the confusion is in the usage of URL as a constructor. More precisely, the original NextURL extended the URL class:
And the PR that changed things: 59f7676 That PR grouped a bunch of things into the so called internals, and stopped extending the URL object. And that's it, the hash is there, because it is part of the URL object. You can use the URL to build a It is not a design issue, nor a bug. But, really, couldn't they just skip it? Well, then you'd get errors with |
Beta Was this translation helpful? Give feedback.
-
I'm on |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
I've been playing around with the latest stable release of Next.js (the App router to be specific) and I noticed something interesting regarding the
nextUrl
property of the request object that's available in middleware. Specifically, I noticed that whenever I try to access thenextUrl.hash
property, I always get an empty string, regardless of whether the URL has a hash or not.I understand that browsers don't send URL hashes to the server, so my question is whether this behavior is intentional or not. If it is, then I'm wondering why the hash property is included in the NextURL class at all, since it seems to always be empty. Wouldn't it make more sense to exclude it altogether?
I'm asking because I want to make sure that I'm not misunderstanding something about how Next.js works, and if this is indeed a bug or a design issue, I'd like to know more about it.
Thank you for your help!
Beta Was this translation helpful? Give feedback.
All reactions