Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for easy enabling CORS #50

Open
sreimond-eodc opened this issue Jul 12, 2023 · 2 comments
Open

Allow for easy enabling CORS #50

sreimond-eodc opened this issue Jul 12, 2023 · 2 comments

Comments

@sreimond-eodc
Copy link

Hello,
in the Tips and Tricks section of the stac-fastapi documentation it is described how to get stac-fastapi working with CORS requests.
I would like to control this easily using the stac-fastapi-pgstac docker compose file, for instance via environment variables. The only way to make this work currently is to clone the repo and edit the app.py myself - or am I missing something?
Thanks!

@m-mohr
Copy link

m-mohr commented Mar 14, 2024

I'm also wondering, why this is not the default? Fundamental tools in the STAC ecosystem such as STAC Browser need it. I'd propose to include CORS by default with an option to disable it. This shouldn't be backend-specific though, so seems more like an issue for stac-fastapi itself.

@vincentsarago
Copy link
Member

I'm also wondering, why this is not the default?

I believe it is https://github.com/stac-utils/stac-fastapi/blob/cae227840ee231ecfdb9b4ef1d187142dfe534ce/stac_fastapi/api/stac_fastapi/api/middleware.py#L21-L31

The CORS middleware is defined in https://github.com/stac-utils/stac-fastapi/blob/main/stac_fastapi/api/stac_fastapi/api/app.py#L111-L115 and this is going to be updated once stac-utils/stac-fastapi#442 gets merged for 3.0.

Sadly I don't see an easy way to support using environment variable for setting CORS options but it should be fairly simple for you to right a really lightweight custom app.py with your wanted configuration

see https://github.com/developmentseed/eoAPI/blob/main/runtime/eoapi/stac/eoapi/stac/app.py#L56-L78

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants