# redirect\_uri is http instead of https

**URL:** <https://community.fly.io/t/redirect-uri-is-http-instead-of-https/6671>\
**Category:** Questions / Help\
**Created:** [August 28, 2022, 2:57pm UTC](https://community.fly.io/t/redirect-uri-is-http-instead-of-https/6671 "2022-08-28T14:57:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorieto](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dorieto](https://community.fly.io/u/dorieto)\
**Post date:** [August 28, 2022, 2:57pm UTC](https://community.fly.io/t/redirect-uri-is-http-instead-of-https/6671/1 "2022-08-28T14:57:57Z")

</div>

Hi, in the process of using oauth I get “http” instead of “https” for parameter redirect\_uri. This is written in python - flask. Is there a setting where I can change how http redirect works?

---

<div class="post-metadata">

**Author:** ![greg](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/greg/32/2119_2.png) [@greg](https://community.fly.io/u/greg)\
**Post date:** [August 28, 2022, 4:01pm UTC](https://community.fly.io/t/redirect-uri-is-http-instead-of-https/6671/2 "2022-08-28T16:01:23Z")

</div>

Hmm. It would depend how that redirect was being done. _If_ your code/library lets you provide an absolute URL to redirect to, you may be able to simply provide one with https at the start.

If not, you could tell Fly to `force_https` in your `fly.toml`? See:

> **[Fly Launch configuration (fly.toml)](https://fly.io/docs/reference/configuration/#services-ports)**
>
> Documentation and guides from the team at Fly.io.

Or if you have some other kind of proxy in front, like you are using Cloudflare, that will likely also have a http-\>https redirect of its own.

---

<div class="post-metadata">

**Author:** ![dorieto](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dorieto](https://community.fly.io/u/dorieto)\
**Post date:** [August 28, 2022, 8:19pm UTC](https://community.fly.io/t/redirect-uri-is-http-instead-of-https/6671/3 "2022-08-28T20:19:31Z")

</div>

hmm I have  
[[services.ports]]  
force\_https = true  
handlers = [“http”]  
port = 80

[[services.ports]]  
handlers = [“tls”, “http”]  
port = 443

When I add force\_https to the bottom ports I get an error because TLS. When I remove TLS I get another error. The library I’m using doesn’t have an option to force a redirect url. I’ve ran same build on Heroku with no issues but am trying to swap over.

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [August 28, 2022, 8:23pm UTC](https://community.fly.io/t/redirect-uri-is-http-instead-of-https/6671/4 "2022-08-28T20:23:43Z")

</div>

If you’re getting TLS errors for a custom hostname, you can add a certificate with `fly certs create example.com`. We’ll generate a certificate if DNS is configured.

Are you trying to just force everything to SSL, or redirect from within your app? If you just want to require ssl, `fly certs create ...` will get you going.

---

<div class="post-metadata">

**Author:** ![dorieto](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dorieto](https://community.fly.io/u/dorieto)\
**Post date:** [August 28, 2022, 10:32pm UTC](https://community.fly.io/t/redirect-uri-is-http-instead-of-https/6671/5 "2022-08-28T22:32:11Z")

</div>

Not using custom hostname atm, first time doing this so a bit hard to explain. I’m using flask oauth for user logins. Whenever I click login the url I’m given is

([https://id.twitch.tv/oauth2/authorize?response\_type=code&client\_id=5v8...f4u&redirect\_uri=http://preferrednames.fly.dev/login/authorized](https://id.twitch.tv/oauth2/authorize?response_type=code&client_id=5v8...f4u&redirect_uri=http://preferrednames.fly.dev/login/authorized))

at the end redirect\_uri should be https not http. That is my current issue.

---

<div class="post-metadata">

**Author:** ![greg](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/greg/32/2119_2.png) [@greg](https://community.fly.io/u/greg)\
**Post date:** [August 28, 2022, 11:38pm UTC](https://community.fly.io/t/redirect-uri-is-http-instead-of-https/6671/6 "2022-08-28T23:38:09Z")

</div>

Ah. _Total_ guess but if you are not providing that URL on the end, it must be figuring it out itself and that would suggest it _thinks_ the incoming connection is http. And so uses http. That would be because (I assume) Fly’s tls handler terminates the tls using its proxy and then forwards an unencrypted connection on to your app. Flask is unaware of this. So … you’d need to tell the oauth code (or Flask) to use https. Check out:

[https://flask-dance.readthedocs.io/en/v0.9.0/proxies.html](https://flask-dance.readthedocs.io/en/v0.9.0/proxies.html)

---

<div class="post-metadata">

**Author:** ![dorieto](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dorieto](https://community.fly.io/u/dorieto)\
**Post date:** [August 28, 2022, 11:44pm UTC](https://community.fly.io/t/redirect-uri-is-http-instead-of-https/6671/7 "2022-08-28T23:44:02Z")

</div>

Yup! That was it, had trouble saying that. I did try another proxyfix earlier that didn’t work. Thank you Grey & Kurt
