

feat: add CORS support, loaded from CORS_ORIGINS in env
@5cf9d1c5ca0ad988dcc123bf4a209b6c467b1177
--- faster_whisper_server/main.py
+++ faster_whisper_server/main.py
... | ... | @@ -77,6 +77,17 @@ |
77 | 77 |
|
78 | 78 |
app = FastAPI() |
79 | 79 |
|
80 |
+cors_origins = os.environ.get("CORS_ORIGINS", "").split(",") |
|
81 |
+if cors_origins: |
|
82 |
+ app.add_middleware( |
|
83 |
+ CORSMiddleware, |
|
84 |
+ allow_origins=cors_origins, |
|
85 |
+ allow_credentials=True, |
|
86 |
+ allow_methods=["*"], |
|
87 |
+ allow_headers=["*"], |
|
88 |
+ ) |
|
89 |
+ |
|
90 |
+ |
|
80 | 91 |
|
81 | 92 |
@app.get("/health") |
82 | 93 |
def health() -> Response: |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?