Host header not included in request anymore

We had built a feature in our app that used the host header to change the branding to match. Aka, one app serving to multiple host names.

Recently this has stopped working. We used to get something like example.com as the content of the host header, but now it will be something like 0.0.0.0:46093 which has broken the feature.

Is there a workaround for this, cause it’s quite annoying to not be able to get the host from the host header.

Here is the network config for the app for reference:

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = false
  auto_start_machines = true
  min_machines_running = 2
  [http_service.concurrency]
    type = "requests"
    hard_limit = 500
    soft_limit = 300

  [[http_service.checks]]
    interval = "5s"
    timeout = "10s"
    grace_period = "5s"
    method = "GET"
    path = "/health"
1 Like

Hi @liamkinne

Sorry for the delay in reply.

I’m trying to reproduce this and couldn’t so far.

Can you describe your setup a bit more? What is your app running (language/framework)? How are you getting the header? How are you making a request?

Based on our https://debug.fly.dev/ app we see the Host header. How are you calling your fly app?

Thanks for looking into this.

It must be an issue with NextJS. Strange because the code hasn’t changed, only the version has been updated.

Will report back with my findings.

Have tried practically every different way of getting the host header or hostname out of NextJS, in the middleware and in the pageInitialProps call. Locally everything is fine, running on fly I get nothing but 0.0.0.0.

Will keep digging.

If you can upload a project to github that we can use to reproduce, it’ll be much easier to debug

I’ve been able to resolve the issue by some combination of changing from an alpine based docker image to the Debian based one suggested by Fly, removing the output: standalone option from my next.config.js, and using the built in Next server rather than a custom server.js.

That last one probably has the most to do with it.

Hope that info helps anyone else who comes across this issues.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.