Skip to content

Commit

Permalink
Merge pull request #176 from ecmwf-projects/fix-cors
Browse files Browse the repository at this point in the history
Add CORS middleware based on DEBUG environment variable
  • Loading branch information
mcucchi9 authored Feb 29, 2024
2 parents dc5270b + 287bf02 commit fe63381
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cads_processing_api_service/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License

import logging
import os
import uuid
from contextlib import asynccontextmanager
from typing import Any, AsyncGenerator, Awaitable, Callable, Mapping, MutableMapping
Expand Down Expand Up @@ -85,11 +86,11 @@ async def initialize_logger(
return response


# FIXME: temporary workaround
app.add_middleware(
fastapi.middleware.cors.CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
if os.environ.get("DEBUG", "0") == "1":
app.add_middleware(
fastapi.middleware.cors.CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

0 comments on commit fe63381

Please sign in to comment.