Next.js Discord

Discord Forum

getstaticprops and headers

Unanswered
West African Lion posted this in #help-forum
Open in Discord
West African LionOP
I want to access the http request header on a page that is rendered using getstaticprops.

The docs say:
getStaticProps does not have access to the incoming request (such as query parameters or HTTP headers) as it generates static HTML. If you need access to the request for your page, consider using Middleware in addition to getStaticProps.

Had anyone successfully implemented this? I can't find any examples, my use case is getting the referrer domain from the request header.

I've played around with some middleware but can't figure out how to access this on the page.

0 Replies