Next 13 App Router Request IP
Answered
Argentine ant posted this in #help-forum
Argentine antOP
Is there a way to get the request IP within an app router component? The component will always be server rendered anad we need to get the request IP as well. I can get the
X-Forwarded-For but we'll sometimes need the raw request IP (the forwarded for header isn't always set). I don't see a way to access the raw IP via the request though?Answered by joulev
Get the request ip in middleware and pass it to the server component as a header
3 Replies
@Argentine ant Is there a way to get the request IP within an app router component? The component will always be server rendered anad we need to get the request IP as well. I can get the `X-Forwarded-For` but we'll sometimes need the raw request IP (the forwarded for header isn't always set). I don't see a way to access the raw IP via the request though?
Get the request ip in middleware and pass it to the server component as a header
Answer
Argentine antOP
thansk @joulev - so basically create a new header from the middleware and then read it with the next 13 app header yeah?