Caught a redirect_uri_mismatch on the dev server: the env file was the localhost one (BOX_REDIRECT_URI=http://localhost:7183/auth/box/callback) which deploy.sh resets on every deploy, so the dev server kept telling Box "redirect me to localhost". Same thing would have hit prod. Switched to request-based detection so the same code works on laptop, dev, and prod: - box_client.build_authorize_url and exchange_code_for_tokens now take redirect_uri as an explicit parameter (the two URIs MUST match — Box rejects the token exchange otherwise). - New _box_redirect_uri() helper in api_server: prefers BOX_REDIRECT_URI if explicitly set (escape hatch), otherwise reads X-Forwarded-Host (set by Apache when behind the optical-dev / optical-prod reverse proxy, where the app is mounted at /ai_qc/), and falls back to request.host for direct local access. - Dropped the per-env BOX_REDIRECT_URI from the four env files. Templates keep it commented out as documentation, and now also list all three redirect URIs you'll need to register in the Box developer console. - box_client.is_configured() no longer gates on the redirect URI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
49 lines
No EOL
1.7 KiB
Text
49 lines
No EOL
1.7 KiB
Text
# Environment Configuration Template
|
|
# Copy this file and rename to development.env or production.env
|
|
# Fill in the appropriate values for your environment
|
|
|
|
# OpenAI Configuration
|
|
OPENAI_API_KEY=your-openai-api-key-here
|
|
GOOGLE_API_KEY=your-google-api-key-here
|
|
|
|
# Azure AD / MSAL Authentication Configuration
|
|
AZURE_TENANT_ID=your-azure-tenant-id
|
|
AZURE_CLIENT_ID=your-azure-client-id
|
|
AZURE_REDIRECT_URI=your-redirect-uri
|
|
|
|
# Flask Configuration
|
|
FLASK_ENV=development
|
|
SECRET_KEY=your-secret-key-here
|
|
DEBUG_MODE=true
|
|
PORT=7183
|
|
|
|
# Application Configuration
|
|
ENVIRONMENT=development
|
|
BASE_URL=http://localhost:7183
|
|
UPLOAD_FOLDER=uploads-dev
|
|
OUTPUT_FOLDER=output-dev
|
|
|
|
# Environment-specific settings
|
|
LOG_LEVEL=DEBUG
|
|
ENABLE_DEBUG_ENDPOINTS=true
|
|
|
|
# Mailgun / SMTP (for outbound email notifications, e.g. access requests)
|
|
SMTP_SERVER=smtp.mailgun.org
|
|
SMTP_PORT=587
|
|
SMTP_USER=your-smtp-username
|
|
SMTP_PASSWORD=your-smtp-password
|
|
SENDER_EMAIL=noreply@your-domain.com
|
|
ERROR_EMAIL=admin@your-domain.com
|
|
REPORT_EMAILS=admin@your-domain.com
|
|
|
|
# Box.com OAuth (per-creator user authentication for automation folders)
|
|
# Register a Custom App with OAuth 2.0 (User Authentication) in Box Developer Console.
|
|
# In the app's Configuration tab, add ALL the redirect URIs you'll use:
|
|
# http://localhost:7183/auth/box/callback (local dev)
|
|
# https://optical-dev.oliver.solutions/ai_qc/auth/box/callback (dev server)
|
|
# https://optical-prod.oliver.solutions/ai_qc/auth/box/callback (prod server)
|
|
# The backend computes the redirect URI from each request, so you don't need
|
|
# to set BOX_REDIRECT_URI per server — uncomment only as an override.
|
|
BOX_CLIENT_ID=your-box-client-id
|
|
BOX_CLIENT_SECRET=your-box-client-secret
|
|
# BOX_REDIRECT_URI= |