W
Wasp4w ago
Kynetix

Google Oauth custom domain goes to fly.io instead of custom domain

I'm hosting my Saas on Fly.io and I've setup a custom domain (say, abcdef.com). I use Google OAuth, and when I log in, it directs to the fly.io domain (abcdef-client.fly.dev)instead of the custom domain (abcdef.com). When I setup the client variables WASP_WEB_CLIENT_URL and WASP_SERVER_URL to abcdef.com, when I log into google I get a 404 (page not found) error. When I set them to their fly.io URLs, it works fine, but the URL shows abcdef-client.fly.dev. How do I remedy it so that it always goes to the custom domain??
2 Replies
kapa.ai
kapa.ai4w ago
Hi @Kynetix. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To ensure Google OAuth redirects and your app use your custom domain (e.g., abcdef.com) instead of the Fly.io subdomain (e.g., abcdef-client.fly.dev), you need to: 1. Set up your custom domain correctly for both client and server. - Add your custom domain to your Fly client app and update DNS records as instructed by Fly.io. This makes your app accessible at your custom domain (see instructions). 2. Set environment variables to your custom domain: - On your server, set WASP_WEB_CLIENT_URL to <https://abcdef.com> (your custom domain). - Set WASP_SERVER_URL to your server’s custom domain (if you have one) or the Fly.io server URL if you’re only customizing the client domain (see details, migration notes). Example:
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://abcdef.com>
wasp deploy fly cmd --context server secrets set WASP_SERVER_URL=<https://abcdef-server.fly.dev>

wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://abcdef.com>
wasp deploy fly cmd --context server secrets set WASP_SERVER_URL=<https://abcdef-server.fly.dev>

3. Update Google OAuth redirect URIs: - In your Google Cloud Console, set the OAuth redirect URI to match your server’s callback endpoint, using the domain where your server is accessible. For most Fly.io setups, this is:
<https://abcdef-server.fly.dev/auth/google/callback>

<https://abcdef-server.fly.dev/auth/google/callback>

If you have a custom domain for your server, use:
<https://api.abcdef.com/auth/google/callback>

<https://api.abcdef.com/auth/google/callback>

- The redirect URI must match exactly what your server uses (see setup guide). 4. Check your routing and deployment: - Make sure your client is deployed and accessible at your custom domain. - Ensure your server is aware of the client’s custom domain via the WASP_WEB_CLIENT_URL variable, so CORS and redirects work as expected. Common pitfalls: - If you set WASP_WEB_CLIENT_URL or WASP_SERVER_URL to the Fly.io subdomain, redirects and CORS will use that domain. - If you set them to your custom domain but the DNS or Fly.io setup isn’t complete, you may get 404 errors or failed redirects. Summary:
You must update both your environment variables and your Google OAuth configuration to use your custom domain. The Fly.io subdomain will only be used if your environment variables or OAuth settings point to it. Double-check that your DNS is set up, your environment variables are correct, and your Google OAuth redirect URIs match your deployed server’s callback endpoint. If you follow these steps and still get a 404, double-check that your custom domain is correctly routed to your deployed client and that the server is accessible from that domain (custom domain setup, env vars, Google OAuth setup). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Kynetix, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
martinsos
martinsos4w ago
Hm really what the bot said here, you need to have that custom domain set up correctly, and you also need to tell Google Auth to redirect to that custom domain. With both of that done correctly, with env vars in Wasp set to that domain also, you should be good. If I were to guess, I would say your custom domain is not correctly configured, be it on the domain provider said or on the Fly side. Check our docs for details on how to set up custom domain for Wasp on Fly: https://wasp.sh/docs/deployment/deployment-methods/wasp-deploy/fly#custom-domain .
Fly.io | Wasp
Fly.io is a platform for running containerized apps and microservices on servers around the world. It makes deploying and managing your apps straightforward with minimal setup.

Did you find this page helpful?