google login custom domain

I tried setting up google login with my custom domain deploying with fly.io and for some reason i tried logging in with google and it never logged in. I checked this out and it seemed to be because of the wasp client url that we have to set.. i had a "/" at the end and maybe that was it. But now when i try to get in to my wasp app that is deployed i cant login with any user or use the google login. Im not sure what happened, but i even deleted the client server from fly and re created it and the problem persists
21 Replies
kapa.ai
kapa.aiβ€’6mo ago
Hi @tomas.morales. 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're experiencing issues with Google Authentication on your Wasp app deployed on a custom domain via Fly.io. Here are a few steps you can take to troubleshoot the issue: 1. Check your Google Configuration and Code: Ensure that your Google configuration and code are set up correctly. In development, it works well on your local machine, which indicates that your Google configuration and code might be correct. However, it's worth double-checking. You can refer to the Wasp Google Auth documentation (https://wasp-lang.dev/docs/auth/social-auth/google) for guidance. 2. Check your Environment Variables: Make sure you've set the necessary environment variables correctly, especially WASP_WEB_CLIENT_URL. This should be set to your custom domain (without a trailing "/"). If you're using an external authentication method like Google, you also need to set the necessary environment variables required by these methods. You can check if you've added your secrets correctly by running flyctl secrets list in the terminal (source (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app)). 3. Set up a Custom Domain: If you're using a custom domain, ensure that you've set it up correctly. This involves adding your domain to your Fly client app, adding the DNS records for your domain, and setting your domain as the WASP_WEB_CLIENT_URL environment variable for your server app (source (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app)). 4. Check your User Database: If you've previously logged in with the same email address using the Email method, it might cause issues. You can run wasp db studio and delete that user, then try logging in again (source (https://discord.com/channels/686873244791210014/1208366712450195466)). If you've checked all of these and the issue persists, it might be helpful to share any error messages you're seeing or more details about your setup. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @tomas.morales, 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?
tomas.morales
tomas.moralesOPβ€’6mo ago
its working fine in local and for some reason it got stuck with the google login problem and now i cant login with any user even after the recreate of the client server i also deleted the created user and all, but it is detecting somehow that it has a user logged in with google and because of the url problem it couldnt "verify" that login.. so that is the problem i am having its weird because now in all my devices (ones that i didnt login before) i cant login with any user ztudia.cl if you want to check out the problem, you will notice the login in landing page is not there and when i put comenzar it takes me to register and i cant register or login i just discovered it seems to be because of the CORS blocking my requests from front end to backend ok solved it, my env var wasnt being set because i missed a space at the end, sorry for the troubles
mb23
mb23β€’6mo ago
@tomas.morales I'm having the same issue. How have you adjust your env var?
tomas.morales
tomas.moralesOPβ€’6mo ago
Your problem is that your front cant call your backend? You need to make sure that you set the env variable for the frontend url in your server That way wasp makes sure the server accepts requests from that url In my case it was setting WASP_WEB_CLIENT_URL=https://ztudia.cl I had a script to add env variables to my server deployed in fly.io and it wasnt taking into account the last env var if i didnt have an empty line at the end of my .env.server.prod file So that was my issue, the variable for frontend url wasnt being set
mb23
mb23β€’6mo ago
@tomas.morales Thanks for your response! I might have a slightly diffrent issue. I'm using Railway, have added all env variables to the Server but still get these issues in the console: signup:1 Access to XMLHttpRequest at 'https://server-production-....railway.app/auth/me' from origin 'https://client-production-....railway.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. index-Bpk1JXu_.js:57 GET https://server-production-....railway.app/auth/me net::ERR_FAILED 401 (Unauthorized)
tomas.morales
tomas.moralesOPβ€’6mo ago
Did you check if the env var is actually set in the server? I also thought i had it until i printed it That cors problem with wasp i would think only comes up with that env var not being correctly set as the server then uses it to allow cors
mb23
mb23β€’6mo ago
@tomas.morales Hmm I think so πŸ˜„ at least, I have added the variables to Railway's variables section of the server
No description
tomas.morales
tomas.moralesOPβ€’6mo ago
And that client url is the same url you use to access your app through the web?
mb23
mb23β€’6mo ago
yeah exactly
tomas.morales
tomas.moralesOPβ€’6mo ago
With https?
mb23
mb23β€’6mo ago
yes (unfortunately haha) Do I maybe have to add REACT_APP_API_URL as an env variable to the .env.client file which is used in production as well?
tomas.morales
tomas.moralesOPβ€’6mo ago
Dont think so its the server blocking, not the client
miho
mihoβ€’6mo ago
Setting the WASP_WEB_CLIENT_URL should be enough πŸ˜„ You can't access the app from the old client URL, only the new one.
Vinny (@Wasp)
Vinny (@Wasp)β€’6mo ago
can you elaborate on this? Where did you deploy to and how did you set your env vars?
tomas.morales
tomas.moralesOPβ€’6mo ago
Its what i said afterwards, i had a script to set env vars and without a space at the end of the envs file it didnt read the last var (the client url)
Vinny (@Wasp)
Vinny (@Wasp)β€’6mo ago
Ah yes missed that. Good to know
tomas.morales
tomas.moralesOPβ€’6mo ago
✌🏾
MEE6
MEE6β€’6mo ago
Wohooo @tomas.morales, you just became a Waspeteer level 3!
martinsos
martinsosβ€’6mo ago
Hey @tomas.morales so you ended up implementing your own .env.server.prod, that is quite cool! We have an issue https://github.com/wasp-lang/wasp/issues/175 where we discuss introduction of such file in a sense that Wasp understands it.
tomas.morales
tomas.moralesOPβ€’6mo ago
Nice! It would be very useful
martinsos
martinsosβ€’6mo ago
@mb23 let's figure out your issue. REACT_APP_API_URL: there is a step here https://wasp-lang.dev/docs/advanced/deployment/manually#deploying-the-client where you were supposed to set it: if you did that, you are good. Make sure you also provided https:// here. But I think you did, that is how your app konws hwere to send those reuqests, and it is sending them to the server, it is just that it gets rejected. We had some good suggestions on how to improve our Railway docs just a couple of days ago, so pls check this: https://github.com/wasp-lang/wasp/issues/2100 -> and see if any advice from here helps you. If not, I woudl suggest you dig into server logs on Railway, for your Wasp server, and see what is happening there - it is likely server is crashing for some reason, it only looks like CORS error, but actually it is sometihng else and it will be obviuos from the server logs.
Want results from more Discord servers?
Add your server