Skip to content

Commit

Permalink
fix: EODAG_CORS_ALLOWED_ORIGINS env var usage
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunato committed Apr 18, 2023
1 parent 03848e7 commit 65c31a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ services:
dockerfile: docker/stac-server.dockerfile
environment:
- "EODAG_LOGGING=${EODAG_LOGGING}"
- "EODAG_CORS_ALLOWED_ORIGINS=http://127.0.0.1:5001"
container_name: stac_server
restart: unless-stopped
networks:
Expand Down
6 changes: 5 additions & 1 deletion eodag/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,11 @@ def serve_rpc(ctx, host, port, conf):
server.serve()


@eodag.command(help="Start eodag HTTP server")
@eodag.command(
help="Start eodag HTTP server\n\n"
"Set EODAG_CORS_ALLOWED_ORIGINS environment variable to configure Cross-Origin Resource Sharing allowed origins as "
"comma-separated URLs (e.g. 'http://somewhere,htttp://somewhere.else')."
)
@click.option(
"-f",
"--config",
Expand Down
5 changes: 3 additions & 2 deletions eodag/rest/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,11 @@ def eodag_openapi():
app.openapi = eodag_openapi

# Cross-Origin Resource Sharing
origins = ["*"]
allowed_origins = os.getenv("EODAG_CORS_ALLOWED_ORIGINS")
allowed_origins_list = allowed_origins.split(",") if allowed_origins else []
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_origins=allowed_origins_list,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
Expand Down

0 comments on commit 65c31a3

Please sign in to comment.