Skip to content

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

@brightonmike

Description

@brightonmike

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

  • I am building using the CLI
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped codev4Issues related to the v4 Next.js runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions