sivakorn-su commited on
Commit
1152e72
·
1 Parent(s): b0d7401

fix Cors origin

Browse files
Files changed (1) hide show
  1. app.py +5 -12
app.py CHANGED
@@ -80,22 +80,15 @@ os.makedirs(UPLOAD_FOLDER, exist_ok=True)
80
 
81
  app = FastAPI()
82
 
83
- origins = [
84
- "https://project-diarzation-production.up.railway.app",
85
- "http://127.0.0.1:8000",
86
- "http://localhost:8000",
87
- "https://huggingface.co/spaces/inwneon/project-voice-diarzation",
88
- "http://127.0.0.1:3000",
89
- "http://localhost:3000",
90
- "http://127.0.0.1:5000",
91
- "http://localhost:5000",
92
- "*"
93
  ]
94
 
95
  app.add_middleware(
96
  CORSMiddleware,
97
- allow_origins=["*"], # หรือระบุให้ชัดเจน ไม่ผสมกัน
98
- allow_credentials=False, # ต้อง False ถ้าใช้ "*"
99
  allow_methods=["*"],
100
  allow_headers=["*"],
101
  )
 
80
 
81
  app = FastAPI()
82
 
83
+ origins = os.getenv("CORS_ORIGINS", "").split(",")
84
+ origins = [o.strip() for o in origins if o.strip()] or [
85
+ "https://project-diarzation-production.up.railway.app"
 
 
 
 
 
 
 
86
  ]
87
 
88
  app.add_middleware(
89
  CORSMiddleware,
90
+ allow_origins=origins,
91
+ allow_credentials=True,
92
  allow_methods=["*"],
93
  allow_headers=["*"],
94
  )