W
Wasp-lang5mo ago
ssor

Oauth provider flow redirects to localhost:3001 instead of 3000

I'm creating a new WASP app from scratch, I've added the Google Provider. My server by default runs on Port 3000 when I wasp start Problem is, when I try and sign in with Google, I'm redirected to http://localhost:3001/auth/google/login I've tried everything inluding changing the Vite config to say:
import { defineConfig } from 'vite'

export default defineConfig({
server: {
open: true,
port: 3000,
},
})
import { defineConfig } from 'vite'

export default defineConfig({
server: {
open: true,
port: 3000,
},
})
And also setting my Server and Client env vars to include these: WASP_WEB_CLIENT_URL=http://localhost:3000 WASP_SERVER_URL=http://localhost:3000
4 Replies
kapa.ai
kapa.ai5mo ago
Hi @ssor_eth. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The behavior you're experiencing is expected. In Wasp, the backend server runs on port 3001 and the frontend server runs on port 3000. When you set up Google Auth in Google Cloud, you have to configure it to redirect to the server, which is why it's redirecting to <http://localhost:3001/auth/google/login> [^1^]. However, starting from Wasp 0.13.0, there were some changes in the OAuth setup due to the switch from Passport to Arctic for OAuth providers. One of these changes is the introduction of a new server environment variable WASP_SERVER_URL which is used to generate the redirect URL for the OAuth providers. In development, Wasp sets the WASP_SERVER_URL to <http://localhost:3001> by default [^5^]. Also, the redirect URL for the OAuth providers has changed. You will need to update the redirect URL for the OAuth providers in the provider's dashboard. The new redirect URL should be {serverUrl}/auth/{provider}/callback [^5^]. For Google, it should be <http://localhost:3001/auth/google/callback> [^6^]. So, in your case, you should set WASP_SERVER_URL=<http://localhost:3001> and update the redirect URL in Google Cloud to <http://localhost:3001/auth/google/callback.> [^1^]: (Source: https://discord.com/channels/686873244791210014/1208366712450195466) [^5^]: (Source: https://wasp-lang.dev/docs/migrate-from-0-12-to-0-13) [^6^]: (Source: https://wasp-lang.dev/docs/auth/social-auth/google#3-creating-a-google-oauth-app) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ssor_eth, 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?
ssor
ssor5mo ago
There are no processes using port 3001 on my system And the callback I'm being redirected to is http://localhost:3001/auth/google/login instead of {serverUrl}/auth/{provider}/callback which the docs say I should be being redirected to Descpite using wasp version 0.13.2 Weird, so I have:
google: {},
gitHub: {}
google: {},
gitHub: {}
These 2 in my auth config. Google is setup with the .env.server client env vars etc but github isn't I wanna get to that later. When I remove github as an oauth option, behaviour is as expected. Guess i need to flesh out Github or remove it as an option
MEE6
MEE65mo ago
Wohooo @ssor_eth, you just became a Waspeteer level 1!
martinsos
martinsos5mo ago
Bot gave some good ansewrs there! There has to be a process using port 3001 on your system if you have run wasp start -> that is where wasp runs the server in dev. It creates two processes, client listening on 3000 and server listening on 3001. You said you are being sent to old callback -> that is because you need to update that callback URL up there in your Google app. I am assuming you were using older Wasp version before and updated it before you got this issue? If so, then you have an old URL up there in the cloud defined for your Google Auth app, you need to make sure it is correct, as per Wasp docs.
Want results from more Discord servers?
Add your server