tus / tus-node-server

Node.js tus server, standalone or integrable in any framework, with disk, S3, and GGC stores.
https://tus.io/
MIT License
795 stars 197 forks source link

generateUrl always returns http protocol #634

Closed KirioXX closed 1 month ago

KirioXX commented 1 month ago

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: https://github.com/tus/tus-node-server/blob/ac78b2ac86546588981ae51d1854106d9326417d/packages/server/src/handlers/BaseHandler.ts#L80-L106

Could it be that that is a bug?

Murderlon commented 1 month ago

@tus/server does not create SSL certificates so it can't be HTTPS by itself. You need a reverse proxy for that.

Helpful links: https://github.com/tus/tus-node-server/tree/main/packages/server#optionsrelativelocation https://github.com/tus/tus-node-server/tree/main/packages/server#optionsrespectforwardedheaders https://github.com/tus/tus-node-server/tree/main/packages/server#example-use-with-nginx

KirioXX commented 1 month ago

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 commented 1 month ago

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

KirioXX commented 1 month ago

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