Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect value for X-Forwarded-Proto #1978

Closed
Tristan971 opened this issue Dec 2, 2023 · 2 comments
Closed

Incorrect value for X-Forwarded-Proto #1978

Tristan971 opened this issue Dec 2, 2023 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Tristan971
Copy link

Tristan971 commented Dec 2, 2023

Environment

Irrelevant but Nitro 2.8.1 on Node 20.5

Reproduction

Issue is visible in:

https://github.com/unjs/nitro/blob/06323b736f0d8adaa609d5a0348fa6b9e0db75e7/src/dev/server.ts#L203-L205

Describe the bug

The X-Forwarded-Proto header should take a value in [http, https], and instead takes a value in [IPv4, IPv6]

With the current code, accessing a Nitro server with plaintext results in X-Forwarded-Proto: IPv4 (for example)

This is not correct, and should instead give X-Forwarded-Proto: http

Additional context

Since it is not a standardised header, the best source of documentation is your pick between:
a. The Mozilla docs about the de-facto way it is meant to work: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto#syntax
b. The spec for the Forwarded header which is based on it (and other X-Forwarded-* friends): https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded#proto
c. Nearly every (widespread) webserver in existence (CF: https://developers.cloudflare.com/fundamentals/reference/http-request-headers/#x-forwarded-proto, AWS: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/x-forwarded-headers.html#x-forwarded-proto, HAProxy: https://docs.haproxy.org/2.8/configuration.html#7.3.1-iif, ...)

Logs

No response

@dpmillerau
Copy link

This is causing me a problem implementing tus-node-server in nuxt

@manniL manniL added bug Something isn't working good first issue Good for newcomers and removed pending triage labels Jan 3, 2024
@manniL
Copy link
Contributor

manniL commented Jan 3, 2024

Seems reasonable IMO. PR Welcome 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants