next-runtime icon indicating copy to clipboard operation
next-runtime copied to clipboard

[Bug]: Cannot access x-forwarded-host in getServerSideProps

Open brightonmike opened this issue 11 months ago • 1 comments

Summary

Locally, including when using netlify dev I can use x-forwarded-host header.

But once deployed, it's not populated. In fact, I can't find a way to access the hostname within getServerSideProps at all.

I'm looking to trigger a function from a page route, and just can't see how to achieve this.

A link to a reproduction repository

https://github.com/on-associates/on-nextjs-template

Expected Result

x-forwarded-host returns site hostname

Actual Result

x-forwarded-host is not populated

Steps to reproduce

  1. Attempt to access context?.req?.headers['x-forwarded-host'] within getServerSideProps

Next Runtime version

4.39.1

Is your issue related to the app directory?

  • [ ] Yes, I am using the app directory

More information about your build

  • [X] I am building using the CLI
  • [X] I am building using file-based configuration (netlify.toml)

What OS are you using?

Mac OS

Your netlify.toml file

[build] command = "yarn build:prod" publish = ".next"

[dev] functions = "functions"

[build.environment] YARN_FLAGS = "--network-timeout 1000000"

[[plugins]] package = "@netlify/plugin-nextjs" [[plugins]] package = "@netlify/plugin-functions-install-core"

[build]

command = "yarn vendors:storybook:build"

publish = "storybook-static/"

Your public/_redirects file

`_redirects`
# Paste content of your `_redirects` file here

Your next.config.js file

`next.config.js`
# Paste content of your `next.config.js` file here. Check there is no private info in there.

Builds logs (or link to your logs)

Build logs
# Paste logs here

Function logs

Function logs
# Paste logs here

.next JSON files

generated .next JSON files
# Paste file contents here. Please check there isn't any private info in them
# You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time.

brightonmike avatar Jul 21 '23 09:07 brightonmike

Thanks for reporting the issue @brightonmike. I've added it to our backlog for the team to investigate.

nickytonline avatar Jul 21 '23 13:07 nickytonline