Skip to main content

Environment Variables

This reference documents all environment variables used across PSS Bids Manager services.

warning

Never commit secrets to version control. Use .env files locally and secure secret management in production.

Shared Variables

These variables must be consistent across all services:

SuperTokens Configuration

VariableDescriptionExample
SUPERTOKENS_CONNECTION_URISelf-hosted SuperTokens Core URLhttp://supertokens:3567
SUPERTOKENS_API_KEYAPI key for SuperTokens Core (if configured)(leave empty for local)
SUPERTOKENS_DASHBOARD_API_KEYDashboard access keyopenssl rand -base64 32

App Domains (Critical for CORS & Cookies)

VariableDescriptionExample
API_DOMAINBackend API base URLhttps://bids.precisionsiteservices.com
WEBSITE_DOMAINFrontend app URLhttps://bids.precisionsiteservices.com
PORTAL_URLAuthentication portal URLhttps://portal.precisionsiteservices.com
warning

Domain configuration is critical. SuperTokens uses these for CORS headers and cookie domains. Mismatched domains will cause authentication failures.

Other Shared Variables

VariableDescriptionExample
GCP_PROJECT_IDGoogle Cloud project IDforge-475221
note

SuperTokens Authentication: ForgeX uses self-hosted SuperTokens Core with Google OAuth. Session management is handled via HTTP-only cookies across all subdomains — no JWT tokens are used.

tip

Generate secure secrets with:

openssl rand -base64 32

Or with Node.js:

node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

Bids Service

Backend (services/bids/backend/.env)

DATABASE_URLstringrequired

PostgreSQL connection string.

Local: postgresql://postgres:devpassword@localhost:5432/bids_db?schema=public

Production: Cloud SQL connection string

SUPERTOKENS_CONNECTION_URIstringrequired

URL of the self-hosted SuperTokens Core instance.

Local: http://supertokens:3567 (Docker Compose)

Production: Your SuperTokens Core deployment URL

GOOGLE_CLIENT_IDstringrequired

Google OAuth Client ID from GCP Console.

Get from: https://console.cloud.google.com/apis/credentials

GOOGLE_CLIENT_SECRETstringrequired

Google OAuth Client Secret from GCP Console.

warning

Keep this secret! Never commit to version control.

ALLOWED_EMAIL_DOMAINSstringrequired

Comma-separated list of allowed email domains.

Example: precisionsiteservices.com,precisionsiteworks.com,sitedrywall.com

Frontend (services/bids/frontend/.env)

VITE_API_URLstringrequired

Backend API URL.

Local: http://localhost:5001/api

Production: https://bids.precisionsiteservices.com/api

VITE_PORTAL_URLstringrequired

Portal URL for authentication.

Local: http://localhost:3000

Production: https://forge.precisionsiteservices.com

VITE_GOOGLE_CLIENT_IDstringrequired

Google OAuth Client ID (same as backend)


Projects Service

Backend (services/projects/backend/.env)

DATABASE_URLstringrequired

PostgreSQL connection string (port 5433 for Projects).

Local: postgresql://postgres:devpassword@localhost:5433/projects_db?schema=public

SUPERTOKENS_CONNECTION_URIstringrequired

Must match Bids service SuperTokens config

BIDS_API_URLstringrequired

Bids service API URL for inter-service calls.

Local: http://localhost:5001/api

Production: https://bids.precisionsiteservices.com/api

SERVICE_TOKENstringrequired

Token for authenticating inter-service API calls


Field Service

Backend (services/field/backend/.env)

DATABASE_URLstringrequired

PostgreSQL connection string (port 5434 for Field).

Local: postgresql://postgres:devpassword@localhost:5434/field_db?schema=public

SUPERTOKENS_CONNECTION_URIstringrequired

Must match Bids and Projects services

PROJECTS_API_URLstringrequired

Projects service API URL.

Local: http://localhost:5002/api

BIDS_API_URLstringrequired

Bids service API URL.

Local: http://localhost:5001/api


Docker Compose Ports

When running with Docker Compose, services use these ports:

ServiceInternal PortExternal Port
Portal30003000
Bids Frontend30013001
Bids Backend50005001
Projects Frontend30023002
Projects Backend50005002
Field Frontend30033003
Field Backend50035003
Bids DB54325432
Projects DB54325433
Field DB54325434

Production Deployment

Cloud Run Environment Variables

Set environment variables in Cloud Run with:

gcloud run deploy bids-backend \
--set-env-vars="NODE_ENV=production" \
--set-env-vars="SUPERTOKENS_CONNECTION_URI=your-production-secret" \
--set-env-vars="DATABASE_URL=postgresql://..." \
--set-env-vars="GOOGLE_CLIENT_ID=..." \
--set-env-vars="GOOGLE_CLIENT_SECRET=..."

Cloud SQL Connection

For Cloud SQL, use the socket path format:

DATABASE_URL=postgresql://user:password@localhost/dbname?host=/cloudsql/PROJECT:REGION:INSTANCE
warning

Do NOT use @/dbname format - this causes empty host errors. Always include @localhost/dbname.

Secret Manager

For sensitive values, consider using Google Secret Manager:

# Create secret
echo -n "your-secret-value" | gcloud secrets create SUPERTOKENS_CONNECTION_URI --data-file=-

# Reference in Cloud Run
gcloud run deploy bids-backend \
--set-secrets="SUPERTOKENS_CONNECTION_URI=SUPERTOKENS_CONNECTION_URI:latest"

Local Development Setup

1
Copy example files
cp services/bids/backend/.env.example services/bids/backend/.env
cp services/bids/frontend/.env.example services/bids/frontend/.env
2
Get Google OAuth credentials
  1. Go to GCP Console
  2. Create OAuth 2.0 Client ID
  3. Copy Client ID and Secret to .env files
3
Configure SuperTokens

Set SUPERTOKENS_CONNECTION_URI in all backend .env files.

Local: http://supertokens:3567 (Docker Compose)

Production: Your SuperTokens Core URL

4
Start services
docker-compose up -d

Troubleshooting

Authentication fails across services

Ensure SUPERTOKENS_CONNECTION_URI and domain config (API_DOMAIN, WEBSITE_DOMAIN) are identical in all backend .env files. SuperTokens cookies must share the same domain (.precisionsiteservices.com in production).

Google OAuth returns error
  1. Verify GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET are correct
  2. Check that redirect URIs are configured in GCP Console
  3. Ensure your email domain is in ALLOWED_EMAIL_DOMAINS
Database connection refused
  1. Check Docker containers are running: docker-compose ps
  2. Verify port mapping matches your DATABASE_URL
  3. For Cloud SQL, check socket path format
Inter-service calls fail
  1. Verify SERVICE_TOKEN matches between services
  2. Check BIDS_API_URL / PROJECTS_API_URL are reachable
  3. In Docker, use service names (e.g., http://bids-backend:5000/api)