Shopify app oauth redirect_uri incorrect format after deployed on fly.io

I have written a very simply Shopify app based on the latest template and I did not touch any part about the OAuth, and the app installed and worked just fine when I run in dev mode. After I deploy it on fly.io, when I try to install it, the redirect_uri in the OAuth url becomes

redirect_uri=little-haze-0000.fly.dev://little-haze-0000.fly.dev/api/auth/callback

, and it gave an error “Oauth error invalid_request: The redirect_uri is not whitelisted” (of course it is wrong!).

Obviously there should be a “https” in front of the “://”. I manually change the parameter to

redirect_uri=https://little-haze-0000.fly.dev/api/auth/callback

and the app can be successfully installed. I looked through the code and app setting in my partner account and can’t find anywhere I can modify the redirect_uri. I wonder where I did wrong?

Hi there :waving_hand:

Could you share what your Shopify object looks like in the Shopify.js file? The redirect URI is using the information from that object to create the redirect URL.

Thank you I have just found the issue by myself. In fly.toml I have missed the “https://” suffix in the HOST parameter:

HOST = "little-haze-0000.fly.dev"

I added the “https://” in front and re-deployed it and it is all good now.

1 Like