Generated by Spark: Should handle caprover / cloudflare cors - Check frontend and backend config. example setup: https://frontend.example.com https://backend.example.com

This commit is contained in:
2026-01-17 18:44:54 +00:00
committed by GitHub
parent 76e7716c10
commit 40b823dfe0
10 changed files with 1135 additions and 3 deletions

View File

@@ -0,0 +1,20 @@
# Backend Environment Variables (Production)
# Allowed CORS origins (comma-separated)
# Use your actual frontend domain(s)
ALLOWED_ORIGINS=https://frontend.example.com,https://www.frontend.example.com
# Server Port
PORT=5001
# Database path (use /data for persistent CapRover volume)
DATABASE_PATH=/data/codeforge.db
# Debug mode (set to 'false' in production)
DEBUG=false
# Optional: API Key for authentication
# API_KEY=your-secure-api-key-here
# Optional: Rate limiting
# RATELIMIT_STORAGE_URL=redis://localhost:6379

View File

@@ -7,7 +7,20 @@ from datetime import datetime
from contextlib import contextmanager
app = Flask(__name__)
CORS(app)
# CORS configuration for CapRover/Cloudflare deployment
# Allow requests from frontend domain
ALLOWED_ORIGINS = os.environ.get('ALLOWED_ORIGINS', '*').split(',')
CORS(app,
resources={r"/api/*": {
"origins": ALLOWED_ORIGINS,
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
"allow_headers": ["Content-Type", "Authorization", "X-Requested-With"],
"expose_headers": ["Content-Type", "X-Total-Count"],
"supports_credentials": True,
"max_age": 3600
}},
supports_credentials=True)
DATABASE_PATH = os.environ.get('DATABASE_PATH', '/data/codeforge.db')
os.makedirs(os.path.dirname(DATABASE_PATH), exist_ok=True)

View File

@@ -0,0 +1,5 @@
{
"schemaVersion": 2,
"dockerfilePath": "./Dockerfile",
"dockerfileLines": []
}