Redirect HTTP to HTTPS?

I’ve got a Node.js server (using Express) and I’d like to make sure all users only get the HTTPS version of my site. What’s the best way to do that with Fly.io?

We don’t have anything built in yet so you’ll need to do it in your app with middleware. Here’s a StackOverflow post showing how:

Just wanted to add for future reference, make sure to not check for url.protocol as well, but only for the X-Forwarded-Proto header as mentioned in Always Be Connecting (with HTTPS).

I checked if url.protocol or X-Forwarded-Proto was http before in my Deno app (which ran here on Fly as well) which, oddly worked without problem and as I was migrating to Remix I just copied this part over expecting it to work the same though it ended up in a redirection loop :scream:

1 Like

We’ve just shipped a feature that tackles this. I think it should cover your use case.

2 Likes