jakeburden / next-absolute-url

Get the absolute URL of your Next.js app (optionally set a localhost dev URL)
300 stars 30 forks source link

Allow comma-separated values of x-forwarded-proto #37

Closed dprgarner closed 1 year ago

dprgarner commented 1 year ago

There's no formal standard on the "x-forwarded-proto" header, but it isn't always a single value like http or https: it's sometimes set to a multi-valued list, like x-forwarded-proto: https,http. If there are multiple protocols, then the absolutely-constructed URL needs to pick one. Otherwise, it constructs a buggy URL like "https,http://example.com"

This PR fixes the protocol to use the first listed protocol from the header. I've also fixed some failing tests and rebuild index.js, which was out-of-sync. (That file should probably not be source-controlled...)

Valerioageno commented 1 year ago

That's a great improvement. What about adding the comma split also over the x-forwarded-host? Even if it is not the Forwarded http header it's the standard de facto.

dprgarner commented 1 year ago

That's a great improvement. What about adding the comma split also over the x-forwarded-host? Even if it is not the Forwarded http header it's the standard de facto.

Sure. I've pushed a commit which does this, too.

jakeburden commented 1 year ago

Merged! Thanks @dprgarner and @Valerioageno! I’ll publish a release on npm with this shortly. It’s a holiday weekend here so may take a day or two. Strongly appreciate you’re work 🙏

jcurtis commented 1 year ago

Any word on publishing the latest @jakeburden ?