Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

req.headers.host is undefined on netlify deployment #40

Closed
s-kris opened this issue Sep 12, 2020 · 9 comments · Fixed by #44
Closed

req.headers.host is undefined on netlify deployment #40

s-kris opened this issue Sep 12, 2020 · 9 comments · Fixed by #44

Comments

@s-kris
Copy link

s-kris commented Sep 12, 2020

I'm trying to read the host in getServerSideProps. It works in local environment with
next dev (obviously)
next build && netlify dev

However when deployed on netlify with this plugin,
req.headers.host is undefined. Any info on this? Thank you.

@FinnWoelm
Copy link
Contributor

Hi @s-kris, thanks for posting the issue!

Hmm, you are right. I just tested with a plain Netlify Function to see what information is available:

exports.handler = function (event, context, callback) {
  callback(null, {
    statusCode: 200,
    headers: {
      "Content-Type": "application/json; charset=utf-8",
    },
    body: JSON.stringify({
      event,
      context,
    }),
  });
};

See results here: https://next-on-functions.netlify.app/.netlify/functions/print

Seems like host is available on headers, but is not available on multiValueHeaders (which is used by next-on-netlify). But we can manually add the host to the multiValueHeaders, that should be fine.

I'll let you know when it's done! 🔥

@s-kris
Copy link
Author

s-kris commented Sep 13, 2020

Awesome, thank you @FinnWoelm

@leomeneguzzi
Copy link
Contributor

leomeneguzzi commented Sep 20, 2020

Hi @FinnWoelm, do you have some updates about it?

@leomeneguzzi
Copy link
Contributor

Hi, I open a really simple PR that solves this issue. I need to do this to my project, just in case my PR be useful to you, I opened the PR. Case not, just close it.

@Yegair
Copy link

Yegair commented Sep 30, 2020

We are currently running into this issue and it prevents us from using next-on-netlify in production, do you have an ETA when this is going to be merged and released?

@abdelhamid-attaby
Copy link

@FinnWoelm can we solve this issue quickly? Our whole business depend on it :)

@FinnWoelm
Copy link
Contributor

Hi all, sorry for the delay in getting this out the door! We were busy refactoring a lot of the codebase last week.

@lindsaylevine just merged the fix into main. The changes should be published to npm within the next 24 hours. If you prefer not to wait, you can already use the latest changes by running npm install netlify/next-on-netlify#main --save. This will give you the cutting-edge version of next-on-netlify right away.

PS: We are super excited that @lindsaylevine has joined Netlify and the next-on-netlify team! 🙌 @lindsaylevine has a ton of experience and will help push next-on-netlify to the next level. You will be seeing a lot of @lindsaylevine going forward 😁 👏

@s-kris
Copy link
Author

s-kris commented Oct 1, 2020

@FinnWoelm @lindsaylevine That's great to hear. Looking forward to new major features. (hint: pure next-inc-ssg support)
Thanks for your awesome work!

@depadiernos
Copy link

depadiernos commented Oct 7, 2020

Just wanted to add here that I added the 'host' header to the multiValueHeaders object for functions on the netlify-side of things to address this issue. It's currently being deployed but should be live on our regular CDN and will be live on our Enterprise CDN soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
6 participants