Next.js Discord

Discord Forum

How to get `req.nextUrl` in server actions | Next 14

Unanswered
Naeemgg posted this in #help-forum
Open in Discord
I'm trying to do some logical stuff depending on from where the request is coming from, in route handlers its easy because of req.nextUrl but I don't know how to get the same thing in server actions.

5 Replies

I just want to know from which domain the request is coming from
https://xyz.com/dash/bla
https://abc.org/bla/..
like these
Is there anyway we can obtain this in server actions?
Asian black bear
afaik u can use headers() in server actions
Ummm could you please elaborate it a bit more
Asian black bear
if u need just domain, can get it from host header
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host