"""titiler app for the 1 m CHM, with the STAC + MosaicJSON docs served locally. titiler's document fetchers (rio-tiler STACReader, cogeo-mosaic web backend) use httpx, which does NOT follow HTTP redirects by default. Hugging Face's `resolve/main` URLs 307-redirect to a CDN, so fetching a STAC item or MosaicJSON straight from the dataset repo fails (the COGs themselves are fine — GDAL follows redirects). We therefore mount the catalog + mosaic as same-origin static files under `/data`, and point the `?url=` params at this Space's own origin. """ from pathlib import Path from fastapi.staticfiles import StaticFiles from titiler.application.main import app _data = Path(__file__).parent / "data" if _data.is_dir(): # e.g. /data/mosaic/chm-1m-eba.json, /data/stac/chm-1m-eba//.json app.mount("/data", StaticFiles(directory=str(_data)), name="data")