So, I'm attempting to pass a user's ip address in my app, as follows:
pages/Item.js
const Item = props => (
<div>
<SingleItem id={props.query.id} userIP={props.userIP} />
</div>
);
Item.getInitialProps = async ({ req }) => {
const userIP = req.headers['x-real-ip'] || req.connection.remoteAddress
return { userIP }
}
export default withAmp(Item, { hybrid: true });
but get the above mentioned error message (See attached image) when navigating to the page. But if I then do a hard reload of the page the ip details are correctly displayed to the page.
What am I overlooking here and is there a better way to achieve this, for example obtaining the ip address from headers in _document.js
?