Next.js Discord

Discord Forum

Help getting URL

Answered
Western harvester ant posted this in #help-forum
Open in Discord
Western harvester antOP
Hello,

I would like some help/example on how I can get the URL that the user is on via the server component.

7 Replies

Western harvester antOP
I really need an option so I can make customized API requests
European sprat
you can try looking in headers() but you might need to add a custom header with the path via middleware if there isn't already a header with the path
Western harvester antOP
Do you have an example how the headers work exactly? I tried using NextRequest but failed to do so.
Answer
Western harvester antOP
omg i got it!
You can just get it from "params" in the generate Metadata!
So happy :D
Thanks anyway :3