Back

Redirect URL sends HTTP instead of HTTPS

  • 0
  • Self Hosted
  • Web
nero125
17 Mar, 2023, 19:00

Hello all, this is my first time posting. I've got read a bunch of article already but I'm still stuck. The problem was about the OAuth redirect_uri.

Upon investigation, when my Appwrite server instance sends OAuth to providers, instead of sending "HTTPS", it sends "HTTP" as protocol for the redirect_url.

My Appwrite instance is running inside my self-hosted server and served via Cloudflare tunnel. I already tried applying host rewrite on my apache configuration but without any luck.

I've attached the screenshots for reference.

Thanks,

TL;DR
The user's Appwrite instance is sending HTTP instead of HTTPS in the redirect URL for OAuth. They tried using "http" instead of "https" and adding a success URL, but it didn't work. There are suggestions to proxy to HTTPS and to ensure that the ProxyPass is set to https:// instead of http://. The user is advised to check the endpoint where they are creating the GitHub OAuth 2 and to deploy the frontend to their server. The user's Apache configuration is shared, and it is confirmed that the Apache is forwarding to HTTPS. There is no solution provided in the thread.
Drake
17 Mar, 2023, 19:11

is your apache forwarding to HTTPS?

nero125
17 Mar, 2023, 19:17

Hi Steven, yes, it is. This is my apache config currently:

TypeScript
   ServerAdmin admin@coffeeandpaste.co
   ServerName appwrite.coffeeandpaste.co

   ProxyPreserveHost On

   ProxyPass / http://localhost:5003/
   ProxyPassReverse / http://localhost:5003/

   RewriteEngine On
   RewriteCond %{HTTP_HOST} !^appwrite\.coffeeandpaste\.co$ [NC]
   RewriteRule ^(.*)$ https://appwrite.coffeeandpaste.co$1 [R=301,L]
</VirtualHost>```
Binyamin
17 Mar, 2023, 19:20

Is the endpoint of when you're creating the GitHub OAuth 2 is HTTP or HTTPS?

nero125
17 Mar, 2023, 19:22

it's HTTPS, I just copied the callback URL provided from the Appwrite console portal

nero125
17 Mar, 2023, 19:22
Binyamin
17 Mar, 2023, 19:22

I mean where you running the createOAuth2Session('github') Your frontend

nero125
17 Mar, 2023, 19:23

ah yes from my frontend

nero125
17 Mar, 2023, 19:23

which is serving locally as of the moment

Binyamin
17 Mar, 2023, 19:25

That's fine but as I saw through the code if this endpoint is not https then the redirects won't be https either So, Create another tunnel to the front end, and give it a try I think it will solve it

nero125
17 Mar, 2023, 19:26

Thanks @Binyamin , I'll try to deploy the frontend to my server and see if it works

nero125
17 Mar, 2023, 19:29

hi @Binyamin , it's still the same, here's the URL of the frontend: https://angular.coffeeandpaste.co/

Binyamin
17 Mar, 2023, 19:30

It gives me an errro

Binyamin
17 Mar, 2023, 19:31

The+redirect_uri+MUST+match+the+registered+callback+URL+for+this+application

Binyamin
17 Mar, 2023, 19:31

You need to add or change so the https://angular.coffeeandpaste.co/ would be the webapp url

Drake
17 Mar, 2023, 19:35

your ProxyPass is to http:// rather than https:// 🧐

Binyamin
17 Mar, 2023, 19:36

Yes @Steven is correct (oc) The AppWrite engine get the request protocol as http

nero125
17 Mar, 2023, 19:41

Hi Steven, I'm ProxyPassing the Appwrite instance served on the docker-compose inside my server, that's why it's http://localhost... Maybe I'll check if I can also forward the origin protocol and use it on the proxy. I'll update this post later. Thanks for all your help 😄

Drake
17 Mar, 2023, 19:52
nero125
17 Mar, 2023, 20:20

Hi Steven and byawitz, using "http" instead of "https" on the OAuth's callback URL works. Also adding success URL on createOAuth2Session() made things work as expected.

Thank you very much!

Binyamin
17 Mar, 2023, 20:20

👍

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more