feat(backoffice): add CORS_ORIGINS env var support
This commit is contained in:
parent
dfdb8bc943
commit
ae7003d3fa
3 changed files with 7 additions and 7 deletions
|
|
@ -27,10 +27,7 @@ BACKEND_HOST=localhost:8521
|
|||
ENV=development
|
||||
|
||||
# CORS Origins (comma-separated)
|
||||
# Development:
|
||||
# CORS_ORIGINS=http://localhost:3000,http://localhost:8963
|
||||
# Production:
|
||||
CORS_ORIGINS=https://gohorsejobs.com,https://gohorsejobs-dev.appwrite.network,https://api-dev2.gohorsejobs.com
|
||||
CORS_ORIGINS=http://localhost:3000,http://localhost:8963
|
||||
|
||||
# =============================================================================
|
||||
# Cloudflare API (for cache management)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ BACKOFFICE_PORT=3001
|
|||
BACKOFFICE_HOST=0.0.0.0
|
||||
NODE_ENV=development
|
||||
|
||||
# CORS Origins (comma-separated)
|
||||
CORS_ORIGINS=https://gohorsejobs.com,https://gohorsejobs-dev.appwrite.network,https://api-dev2.gohorsejobs.com
|
||||
|
||||
# =============================================================================
|
||||
# Stripe
|
||||
# =============================================================================
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ async function bootstrap() {
|
|||
// CORS configuration (Fastify-native)
|
||||
app.enableCors({
|
||||
origin: (origin, callback) => {
|
||||
// Parse CORS_ORIGINS from env (comma-separated)
|
||||
const envOrigins = process.env.CORS_ORIGINS?.split(',').map(o => o.trim()) || [];
|
||||
const allowedOrigins = [
|
||||
'http://localhost:3000',
|
||||
'http://localhost:8963',
|
||||
'https://gohorsejobs.com',
|
||||
'https://admin.gohorsejobs.com',
|
||||
process.env.FRONTEND_URL,
|
||||
...envOrigins,
|
||||
].filter(Boolean);
|
||||
|
||||
if (!origin || allowedOrigins.includes(origin)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue