Replies: 1 comment
-
If you want to get the request object while on the server, you would have to do it something like this on each page: export async function getServerSideProps(context) {
const { req } = context
return {
props: {},
}
} You could alternatively use a custom |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I'm wondering if anyone has any decent solutions for accessing the req object from anywhere while running in Node. Similar to how we can use
withRouter
HOC anduseRouter
anywhere in React land... I'd like to be able to do something similar with the req object.I found this: #7393. But the accepted solution appears to be one using a custom server. Does anyone have any ideas for how to accomplish this without a custom server?
More specifically, on the client, I can do this:
window.location.host
to get the host. I need to be able to do something similar on the server. Ideally, if I could write some sort of function like:Beta Was this translation helpful? Give feedback.
All reactions