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

CORS not working properly for stac-fastapi with stac-browser #203

Open
ianhorn opened this issue Jan 7, 2025 · 4 comments
Open

CORS not working properly for stac-fastapi with stac-browser #203

ianhorn opened this issue Jan 7, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@ianhorn
Copy link

ianhorn commented Jan 7, 2025

Problem description

All the API urls work when I start the containers. I'm even able to access the http://:8081/api.html; however, the STAC-Browser still says I don't have CORS-enabled for 8081.

Expected Output

I added the following to the environment for the fastapi. I removed my ec2 dns

      - CORS_ALLOW_ORIGINS=*
      - CORS_ALLOW_METHODS=GET, POST, PUT, DELETE
      - CORS_ALLOW_HEADERS=Content-Type,Authorization
      - ALLOWED_ORIGINS=*
      - CORS_ORIGINS=*
      - CORS_ORIGINS=<http://ec2DNS>:8085,*
      - API_URL=http://<ec2dns>:8081

Environment Information

EC2 - AMI Amazon Linux 2023
Docker

@ianhorn ianhorn added the bug Something isn't working label Jan 7, 2025
@vincentsarago
Copy link
Member

It depends on your stac-fastapi-pgstac version, the CORS configuration by env variable is available just from 3.0.1 https://github.com/stac-utils/stac-fastapi-pgstac/blob/main/CHANGES.md#301---2024-11-14

stac-utils/stac-fastapi-pgstac#170

@ianhorn
Copy link
Author

ianhorn commented Jan 7, 2025

Thanks for your response. I updated the image verison for the docker-compose. All the urls work fine still, but now when I open up http://dns:8085 all I see is the title and white page and it's just loading. No console errors or anything. The stac api endpoint still says cors error in radiant earth's stac-browser.

I'm just going to back to using the stac-fastapi-pgstac repo because it was working fine. Maybe I'll try to add the titiler and then stac-browser to that docker-compose.yml.

Thanks again for your help. These are beautiful tools.

@neoporteria
Copy link

I'm also having some problems with the local stac-browser. I'm using stac-fastapi-pgstac:4.0.1 with the cors origin and method env vars.

  - CORS_ORIGINS=*
  - CORS_METHODS=GET,POST,OPTIONS

whenever i try to open the catalog in the local browser i got the CORS header message, but if i use localhost:8081 on radiantearth stac-browser i don't have any problem opening it

@ianhorn
Copy link
Author

ianhorn commented Feb 11, 2025

I believe the issue is unrelated to CORS. What I believe is going on is my API url is a domain name, but the links are still getting created as localhost. Stac-browser does does not like the mixing of the two.

Is there somewhere in the docker-compose.yml to set the API url?

API: https://kygislicserv.ky.gov/kystac-api

"links": [
{
"rel": "self",
"type": "application/json",
"href": "http://localhost:8082/"
},
{
"rel": "root",
"type": "application/json",
"href": "http://localhost:8082/"
},
{
"rel": "data",
"type": "application/json",
"href": "http://localhost:8082/collections"
},
{
"rel": "conformance",
"type": "application/json",
"title": "STAC/OGC conformance classes implemented by this server",
"href": "http://localhost:8082/conformance"
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants