From 2851f3df0af91ad2bb0ebfdfdbd4803100ddee96 Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Fri, 30 Jan 2026 05:31:51 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20environment=20preparation?= =?UTF-8?q?=20step=20for=20setting=20up=20Discord=20redirect=20URI=20befor?= =?UTF-8?q?e=20building?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/websites/pokedex.online/deploy.sh | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/code/websites/pokedex.online/deploy.sh b/code/websites/pokedex.online/deploy.sh index cec0e5a..77c7a23 100755 --- a/code/websites/pokedex.online/deploy.sh +++ b/code/websites/pokedex.online/deploy.sh @@ -209,6 +209,41 @@ run_tests() { # Build ############################################################################### +prepare_env_for_build() { + # Create/update .env.local with correct Discord redirect URI for the target + local env_file="$PROJECT_ROOT/.env.local" + local redirect_uri + + # Determine correct redirect URI based on target and ports + case "$TARGET" in + local) + # For Docker, use the frontend port + redirect_uri="http://localhost:${PORT}/oauth/callback" + ;; + internal|external) + # For dev server, use default Vite port + redirect_uri="http://localhost:5173/oauth/callback" + ;; + *) + redirect_uri="http://localhost:5173/oauth/callback" + ;; + esac + + log_info "Preparing environment for ${TARGET} deployment..." + log_info "Discord redirect URI: ${redirect_uri}" + + # Create/update .env.local with Discord credentials + cat > "$env_file" << EOF +# Generated by deploy.sh for ${TARGET} deployment +# These variables are embedded into the frontend bundle at build time + +VITE_DISCORD_CLIENT_ID=1466544972059775223 +VITE_DISCORD_REDIRECT_URI=${redirect_uri} +EOF + + log_info ".env.local created with correct redirect URI" +} + build_application() { if [ "$SKIP_BUILD" = true ]; then log_warning "Skipping build (--skip-build flag set)" @@ -224,6 +259,9 @@ build_application() { log_step "🔨 Building Application" + # Prepare environment before building + prepare_env_for_build + log_info "Building frontend..." npm run build:frontend || { log_error "Frontend build failed"