W
Wasp•4w ago
ApexFossa45

How to redirect from server in google oath 2.0 to my new domain?

Hi, having issues with redirecting from google oath 2.0, which points to the fly io server (ai-creations-central-server.fly.dev/auth/google/callback) for the authentication, and it works succesfully. But when logging in using google auth, it redirects to the fly io dns: https://ai-creations-central-client.fly.dev/ question is, how do i get it to redirect to my new dns (which is working): https://aicreationscentral.com ? Thank you in advance
14 Replies
kapa.ai
kapa.ai•4w ago
Hi @ApexFossa45. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To redirect from Google OAuth 2.0 to your new domain (https://aicreationscentral.com) instead of the Fly.io URL, you need to make a few changes to your Wasp app configuration. Here's how you can do it: 1. Update Google OAuth App settings: First, you need to add your new domain to the authorized redirect URIs in your Google OAuth app settings. Go to the Google Cloud Console, find your project, and add <https://aicreationscentral.com/auth/google/callback> to the list of authorized redirect URIs. Google OAuth App Setup (https://wasp-lang.dev/docs/auth/social-auth/google#3-creating-a-google-oauth-app) 2. Update the WASP_WEB_CLIENT_URL environment variable: You need to set the WASP_WEB_CLIENT_URL environment variable for your server app to your new domain. Run the following command:
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://aicreationscentral.com>

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

This updates the CORS configuration to allow requests from your new domain. Custom Domain Setup (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app) 3. Set up DNS records: Ensure that you have set up the correct DNS records for your custom domain. You should have an A record and an AAAA record pointing to your Fly.io app. Custom Domain Setup (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app) 4. Update the server URL: Make sure you've also set the WASP_SERVER_URL environment variable to your new server URL (if it has changed). This is important for proper redirection when using OAuth providers. Server Environment Variables (https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables) 5. Redeploy your app: After making these changes, redeploy your Wasp app to Fly.io to ensure all the new configurations are applied. If you've followed these steps and are still experiencing issues, you might want to double-check that all your environment variables are set correctly. You can list your secrets on Fly.io using the command:
flyctl secrets list
flyctl secrets list
Remember that the secrets will be shown as hashed values to protect sensitive data. Fly.io Secrets (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app) If you're still having trouble after following these steps, it might be worth upgrading to the latest version of Wasp, as some recent updates have fixed similar issues. Upgrading Wasp (https://discord.com/channels/686873244791210014/1201898985300971540) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ApexFossa45, 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?
ApexFossa45
ApexFossa45OP•4w ago
@kapa.ai thank you, i will try point 2. the dns is already worrking. i may not need to update the server url, i was thinking i just use the existing, the redirect is the issue
kapa.ai
kapa.ai•4w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- You're welcome! I'm glad to help. Your approach sounds good, and you're right that focusing on updating the WASP_WEB_CLIENT_URL (point 2) is likely the key to solving your redirect issue. Since your DNS is already working and you're planning to continue using the existing server URL, here's what you should do: 1. Update the WASP_WEB_CLIENT_URL environment variable: Run the following command to set the WASP_WEB_CLIENT_URL to your new domain:
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://aicreationscentral.com>

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

This step is crucial because it tells your Wasp server where to redirect after successful authentication Server Configuration (https://wasp-lang.dev/docs/advanced/accessing-app-config#server-configuration-object). 2. After setting the new WASP_WEB_CLIENT_URL, make sure to redeploy your server app on Fly.io to apply the changes. 3. Double-check that your Google OAuth app settings include <https://aicreationscentral.com/auth/google/callback> in the authorized redirect URIs Google OAuth Setup (https://wasp-lang.dev/docs/auth/social-auth/google#3-creating-a-google-oauth-app). By updating the WASP_WEB_CLIENT_URL, you're essentially telling your Wasp app where the frontend is located, which should resolve the redirect issue. If you encounter any problems after making this change, please let me know, and we can troubleshoot further. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ApexFossa45, 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?
ApexFossa45
ApexFossa45OP•4w ago
@kapa.ai thank you, it worked!
kapa.ai
kapa.ai•4w ago
Let me check the knowledge base for you again. One moment! :books:
MEE6
MEE6•4w ago
Wohooo @ApexFossa45, you just became a Waspeteer level 2!
kapa.ai
kapa.ai•4w ago
---------------------- I'm delighted to hear that it worked for you! Thank you for letting me know. It's great that updating the WASP_WEB_CLIENT_URL environment variable solved your redirect issue. If you have any more questions about Wasp or encounter any other challenges while developing your application, please don't hesitate to ask. Good luck with your project! ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ApexFossa45, 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?
Filip
Filip•3w ago
Nice to see the bot is useful 🙂 @ApexFossa45 That's for training it!
Filip
Filip•3w ago
Btw, this is already covered in the docs: https://wasp-lang.dev/docs/advanced/deployment/cli#environment-variables But that part of the docs is pretty chaotic and currently going through an overhaul. So, on that note, can you tell us where you looked for this info or how you think it makes sense to present it (any ideas at all)? It will help us do a better job with the new docs
Deploying with the Wasp CLI | Wasp
Wasp CLI can deploy your full-stack application with only a single command.
ApexFossa45
ApexFossa45OP•3w ago
(sorry for late reply). Yep, thank you. The bot is very helpful to me :boi: Hmmm. Interesting yes I remember looking at those docs to get my domain and dns set up (i'm using aws route 53 and namecheap). That is true, it is there, i must have missed it! it's in step 3. The thing is, I did it much after because I was trying to get the dns connection to work, which thankfully I did after doing some research online. As for the general overview to present it, I think keeping it there in step 3 is good. I wouldn't change it too much unless other people also have the similar issues. Maybe like highlighting/changing the background color, adding borders for Fly.io and API Reference would set a clear separation for the end-users. just a thought. thanks!
Filip
Filip•2w ago
Thanks! That's valuable feedback. I'll tag @miho because he's working on those docs and would probably like to read it
miho
miho•2w ago
Thank you for the tag @Filip
Maybe like highlighting/changing the background color, adding borders for Fly.io and API Reference would set a clear separation for the end-users.
@ApexFossa45 good insight!
NEROX
NEROX•2w ago
I recorded a tutorial a time ago about this: https://www.loom.com/share/4bd3e1000e5d4afabf8f907b2b18a820 about how to set a domain like api. to the fly server URL
ApexFossa45
ApexFossa45OP•2w ago
no problem, and thanks team for the continued support! :boi:
Want results from more Discord servers?
Add your server