mirror of
https://github.com/reconurge/flowsint.git
synced 2026-07-21 12:50:12 -05:00
fix(api): restrict CORS origins via ALLOWED_ORIGINS env
allow_origins was ["*"] together with allow_credentials=True, which is both insecure and rejected by browsers for credentialed requests. Read a comma-separated ALLOWED_ORIGINS env var instead, defaulting to the Vite dev origin http://localhost:5173. Documented in .env.example.
This commit is contained in:
@@ -6,5 +6,7 @@ NEO4J_URI_BOLT=bolt://neo4j:7687
|
||||
NEO4J_USERNAME=neo4j
|
||||
NEO4J_PASSWORD=password
|
||||
VITE_API_URL=http://127.0.0.1:5001
|
||||
# Comma-separated CORS allowed origins. Defaults to http://localhost:5173 (Vite dev) when unset.
|
||||
ALLOWED_ORIGINS=http://localhost:5173
|
||||
DATABASE_URL=postgresql://flowsint:flowsint@localhost:5433/flowsint
|
||||
REDIS_URL=redis://redis:6379/0
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
@@ -16,8 +18,12 @@ from app.api.routes import types
|
||||
from app.api.routes import custom_types
|
||||
from app.api.routes import enricher_templates
|
||||
|
||||
# Comma-separated list of allowed origins, e.g. "https://app.example.com,https://staging.example.com"
|
||||
# Falls back to localhost dev origin when unset. Never use "*" with allow_credentials=True.
|
||||
origins = [
|
||||
"*",
|
||||
o.strip()
|
||||
for o in os.getenv("ALLOWED_ORIGINS", "http://localhost:5173").split(",")
|
||||
if o.strip()
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user