🔧 Add environment preparation step for setting up Discord redirect URI before building
This commit is contained in:
@@ -209,6 +209,41 @@ run_tests() {
|
|||||||
# Build
|
# 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() {
|
build_application() {
|
||||||
if [ "$SKIP_BUILD" = true ]; then
|
if [ "$SKIP_BUILD" = true ]; then
|
||||||
log_warning "Skipping build (--skip-build flag set)"
|
log_warning "Skipping build (--skip-build flag set)"
|
||||||
@@ -224,6 +259,9 @@ build_application() {
|
|||||||
|
|
||||||
log_step "🔨 Building Application"
|
log_step "🔨 Building Application"
|
||||||
|
|
||||||
|
# Prepare environment before building
|
||||||
|
prepare_env_for_build
|
||||||
|
|
||||||
log_info "Building frontend..."
|
log_info "Building frontend..."
|
||||||
npm run build:frontend || {
|
npm run build:frontend || {
|
||||||
log_error "Frontend build failed"
|
log_error "Frontend build failed"
|
||||||
|
|||||||
Reference in New Issue
Block a user