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

generateUrl always returns http protocol #634

Closed
KirioXX opened this issue Jul 11, 2024 · 4 comments
Closed

generateUrl always returns http protocol #634

KirioXX opened this issue Jul 11, 2024 · 4 comments

Comments

@KirioXX
Copy link

KirioXX commented Jul 11, 2024

Hi!
I setup tus server in my node project with a custom path.
The problem I found is that on my server the generateUrl function didn't return https as a protocol what made the client fail because it got a 301 code.
I checked the function that should return the right protocol but I can't see that it ever would return https:

protected extractHostAndProto(req: http.IncomingMessage) {
let proto
let host
if (this.options.respectForwardedHeaders) {
const forwarded = req.headers.forwarded as string | undefined
if (forwarded) {
host ??= reForwardedHost.exec(forwarded)?.[1]
proto ??= reForwardedProto.exec(forwarded)?.[1]
}
const forwardHost = req.headers['x-forwarded-host']
const forwardProto = req.headers['x-forwarded-proto']
// @ts-expect-error we can pass undefined
if (['http', 'https'].includes(forwardProto)) {
proto ??= forwardProto as string
}
host ??= forwardHost
}
host ??= req.headers.host
proto ??= 'http'
return {host: host as string, proto}
}

Could it be that that is a bug?

@Murderlon
Copy link
Member

@Murderlon Murderlon closed this as not planned Won't fix, can't repro, duplicate, stale Jul 11, 2024
@KirioXX
Copy link
Author

KirioXX commented Jul 11, 2024

Thanks for the quick response Murderlon.
I actually just run my app in a docker container and my hosting provider (railway.app)
is handling the certificate and networking.
Should the protocol not then come from the request?

@Murderlon
Copy link
Member

If whatever is making requests to your tus server is on the same domain, easiest would be to use relativeLocation.

@KirioXX
Copy link
Author

KirioXX commented Jul 11, 2024

Ok perfect thank you Murderlon! I will do that then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants