Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access express req inside next.js App

Suppose I have a middleware that adds some data fields to express.js req object. I want to inject these fields into my React components through my Next.js _app.js implementation. How do I access req inside _app.js?

like image 896
Gherman Avatar asked May 04 '26 12:05

Gherman


1 Answers

try this static async getInitialProps({ Component, ctx }) { and inside the function ctx.req

like image 174
evgeni fotia Avatar answered May 06 '26 01:05

evgeni fotia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!