Skip to content

Commit cdb6b71

Browse files
bjgiraudonGIRAUDON Benjamin
andauthored
fix: properly handle port with forwarded header (#17)
This MR adds an old commit from Gitlab fixing the port issues on the Forwarded headers. It fixes an issue where ports would be displayed in STAC links objects. Co-authored-by: GIRAUDON Benjamin <benjamin.giraudon@cs-soprasteria.com>
1 parent 770e47a commit cdb6b71

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies = [
2121
"stac-fastapi.extensions",
2222
"stac-fastapi.types",
2323
"stac-pydantic==3.1.*",
24+
"brotli-asgi",
2425
"starlette",
2526
"typing_extensions",
2627
]

stac_fastapi/eodag/app.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323
from typing import TYPE_CHECKING
2424

2525
import stac_fastapi.api.errors
26+
from brotli_asgi import BrotliMiddleware # type: ignore[import-untyped]
2627
from fastapi import FastAPI
2728
from fastapi.concurrency import asynccontextmanager
29+
from fastapi.middleware import Middleware
2830
from fastapi.responses import ORJSONResponse
2931
from stac_fastapi.api.app import StacApi
32+
from stac_fastapi.api.middleware import CORSMiddleware
3033
from stac_fastapi.api.models import (
3134
EmptyRequest,
3235
ItemCollectionUri,
@@ -63,6 +66,7 @@
6366
ViewGeometryExtension,
6467
)
6568
from stac_fastapi.eodag.logs import RequestIDMiddleware, init_logging
69+
from stac_fastapi.eodag.middlewares import ProxyHeaderMiddleware
6670
from stac_fastapi.eodag.models.stac_metadata import create_stac_metadata_model
6771

6872
if TYPE_CHECKING:
@@ -172,6 +176,11 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
172176
search_post_request_model=search_post_model,
173177
collections_get_request_model=collections_model,
174178
items_get_request_model=item_collection_model,
179+
middlewares=[
180+
Middleware(BrotliMiddleware),
181+
Middleware(CORSMiddleware),
182+
Middleware(ProxyHeaderMiddleware),
183+
],
175184
)
176185

177186

0 commit comments

Comments
 (0)