diff --git a/.github/workflows/deploy-webapp.yml b/.github/workflows/deploy-webapp.yml index dcefe00..7380095 100644 --- a/.github/workflows/deploy-webapp.yml +++ b/.github/workflows/deploy-webapp.yml @@ -40,6 +40,7 @@ jobs: --build-arg NEXT_PUBLIC_HCS_TOPIC_ID="${{ vars.NEXT_PUBLIC_HCS_TOPIC_ID }}" \ --build-arg NEXT_PUBLIC_AUTH0_REDIRECT_URI="${{ vars.NEXT_PUBLIC_AUTH0_REDIRECT_URI }}" \ --build-arg NEXT_PUBLIC_AUTH0_POST_LOGOUT_REDIRECT_URI="${{ vars.NEXT_PUBLIC_AUTH0_POST_LOGOUT_REDIRECT_URI }}" \ + --build-arg NEXT_PUBLIC_ONBOARDING_URL="${{ vars.NEXT_PUBLIC_ONBOARDING_URL }}" \ -t $ECR_REGISTRY/$ECR_REPOSITORY:latest . docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest diff --git a/src/components/AuthGuard.tsx b/src/components/AuthGuard.tsx index 0af7635..6ce9c69 100644 --- a/src/components/AuthGuard.tsx +++ b/src/components/AuthGuard.tsx @@ -46,7 +46,14 @@ export default function AuthGuard() { // We allow /public and /unauthorized pages (for error pages) if (!token && !pathname.startsWith("/public") && !pathname.startsWith("/unauthorized")) { const redirectUrl = encodeURIComponent(window.location.href); - window.location.href = `http://localhost:3000/auth/authenticate?redirect=${redirectUrl}`; + const onboardingUrl = process.env.NEXT_PUBLIC_ONBOARDING_URL; + + if (!onboardingUrl) { + console.error("NEXT_PUBLIC_ONBOARDING_URL is not defined"); + return; + } + + window.location.href = `${onboardingUrl}/auth/authenticate?redirect=${redirectUrl}`; return; }