W
Wasp-langβ€’2mo ago
Jithu

Google auth redirects to fly.dev domain instead of custom domain

After deploying my app, when I try to sign in with google, I am reditected to https://my-application.fly.dev/auth/google/login instead of https://my-application.com/auth/google/login I have changed the WASP_SERVER_URL to point to my custom domain
12 Replies
kapa.ai
kapa.aiβ€’2mo ago
Hi @Jithu. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- It seems like you've done the right thing by setting the WASP_SERVER_URL to your custom domain. However, you also need to ensure that the WASP_WEB_CLIENT_URL environment variable is set to your custom domain. This is necessary for the server to properly configure Same-Origin Policy (CORS) headers. You can set this environment variable by running the following command:
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://mycoolapp.com>
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://mycoolapp.com>
Make sure to replace mycoolapp.com with your custom domain. Also, if you're using Google authentication, ensure that you've set the necessary environment variables specifically required by this method. You can find more information about this in the Wasp documentation (https://wasp-lang.dev/docs/auth/social-auth/google#4-adding-environment-variables). After setting these environment variables, your app should be available at <https://mycoolapp.com> and Google authentication should redirect to your custom domain. If you want to make sure you've added your secrets correctly, you can run flyctl secrets list in the terminal. Note that you will see hashed versions of your secrets to protect your sensitive data. Sources: - Wasp Docs: Deploying Manually (https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables) - Wasp Docs: Using a Custom Domain For Your App (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app) - Wasp Docs: Set Up a Fly.io App (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Jithu, 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?
Jithu
Jithuβ€’2mo ago
I have set the WASP_WEB_CLIENT_URL aswell to point to my custom domain. I still have the same issue
miho
mihoβ€’2mo ago
1. After a successful login to Google, Google will redirect to the server URL. 2. The server URL then redirects to the client URL. The server env vars: - WASP_WEB_CLIENT_URL should be set to your custom domain e.g. https://myapp.com - WASP_SERVER_URL should be set to the server url e.g. https://serverapp.fly.dev or if you set a custom domain there as well https://api.myapp.com
Jithu
Jithuβ€’2mo ago
Hi @miho Thank you for getting back to me. I have tried setting both the client and server variables as custom domains. I have also tried setting the server url as fly.dev server url. In my case when I click the google login button it is still redirecting to the fly.dev url. If I add fly.dev url to google auth authorized redirect urls in the google console, it is working properly. But I don't want to add fly.dev url to the google console as it may not be approved as I don't own the domain fly.dev. So I was looking for a method to only redirect to the custom domain.
miho
mihoβ€’2mo ago
But I don't want to add fly.dev url to the google console as it may not be approved as I don't own the domain fly.dev
I've never had issues with the approval from Google πŸ™‚ I think they understand it's a common subdomain πŸ˜„ Could you maybe try using the .fly.dev subdomain and seeing if things work for you?
Jithu
Jithuβ€’2mo ago
Sure, I am going to try that. Thank you πŸ™‚
samim
samimβ€’5w ago
@kapa.ai By trying to authenticate with email / sign up or login or using the google authentication, I get the following error in the console#. [Error] Failed to load resource: Es wurde kein Server mit dem angegebenen Hostnamen gefunden. (me, line 0) https://etal-server.fly.dev/auth/me
kapa.ai
kapa.aiβ€’5w ago
Let me check the knowledge base for you. One moment! :books: ---------------------- The error message you're seeing, "Failed to load resource: Es wurde kein Server mit dem angegebenen Hostnamen gefunden" translates to "Failed to load resource: No server with the specified hostname was found". This suggests that the server at the URL <https://etal-server.fly.dev/auth/me> is not reachable. Here are a few things you can check: 1. Server URL: Make sure that the server URL is correct and the server is running. If you're running the server locally, the URL should be <http://localhost:3001/auth/me.> If the server is deployed, make sure the deployed server URL is correct. 2. Environment Variables: Check your environment variables. If you're using Google authentication, ensure that you've set the necessary environment variables specifically required by this method. You can find more information about this in the Wasp documentation (https://wasp-lang.dev/docs/auth/social-auth/google#4-adding-environment-variables). 3. CORS Policy: If you're seeing this error in your browser console, it might be due to the CORS policy. Make sure that your server is set up to accept requests from the origin your requests are coming from. If you're still having trouble, it would be helpful to see any additional error messages or logs. Also, knowing more about your setup (e.g., are you running this locally or is it deployed, which authentication methods are you using, etc.) could help diagnose the issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @samim, 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?
samim
samimβ€’5w ago
@kapa.ai well the server URL is not reachable, however, if I check the fly app, the url there provided is etal.fly.dev
kapa.ai
kapa.aiβ€’5w ago
Let me check the knowledge base for you. One moment! :books: ---------------------- It seems like there might be a discrepancy between the server URL you're using and the one provided by Fly.io. If Fly.io is providing etal.fly.dev as the URL, then this is the URL you should be using as your WASP_SERVER_URL. You can set this environment variable by running the following command:
wasp deploy fly cmd --context server secrets set WASP_SERVER_URL=<https://etal.fly.dev>
wasp deploy fly cmd --context server secrets set WASP_SERVER_URL=<https://etal.fly.dev>
After setting this environment variable, try to access your server again at <https://etal.fly.dev/auth/me.> If you're still having trouble, you can check the logs of your Fly.io app by running flyctl logs in the terminal. This might give you more information about what's going wrong. Sources: - Wasp Docs: Deploying Manually (https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables) - Wasp Docs: Set Up a Fly.io App (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @samim, 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?
samim
samimβ€’5w ago
@kapa.ai I did it, and set the wasp_server_url=https://etal.fly.dev but it still doesn't work and same issue
My Open SaaS App
I made a SaaS App. Buy my stuff.
kapa.ai
kapa.aiβ€’5w ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I'm sorry to hear that you're still experiencing issues. Here are a few more things you could try: 1. Check the Client URL: Make sure that the WASP_WEB_CLIENT_URL is also set correctly. This should be the URL where your frontend app is running. You can set it with a similar command:
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://<your-client-url>>
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://<your-client-url>>
Replace <your-client-url> with the actual URL of your client. 2. Redeploy Your App: After setting the environment variables, you might need to redeploy your app for the changes to take effect. You can do this by running flyctl deploy --remote-only --config ../../fly.toml from the .wasp/build/ directory. 3. Check Your DNS Settings: If the server is still not reachable, there might be an issue with your DNS settings. If you're using a custom domain, make sure you've followed the instructions for setting up a custom domain (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app) correctly. 4. Check the Logs: You can check the logs of your Fly.io app by running flyctl logs in the terminal. This might give you more information about what's going wrong. If none of these suggestions help, it might be a good idea to reach out to the Wasp community or the Fly.io support for further assistance. Sources: - Wasp Docs: Deploying Manually (https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables) - Wasp Docs: Deploy to a Fly.io App (https://wasp-lang.dev/docs/advanced/deployment/manually#deploy-to-a-flyio-app) - Wasp Docs: Using a Custom Domain For Your App (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @samim, 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?
Want results from more Discord servers?
Add your server