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 7, 2023
1 parent 2ebc140 commit e859544
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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 e859544

Please sign in to comment.