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

How to enable CORS headers with terracotta serve? #197

Closed
j08lue opened this issue Apr 23, 2021 · 6 comments
Closed

How to enable CORS headers with terracotta serve? #197

j08lue opened this issue Apr 23, 2021 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@j08lue
Copy link
Collaborator

j08lue commented Apr 23, 2021

When trying the new terracotta preview against a locally run terracotta serve, I get errors because of missing CORS headers.

This issue is popping up now, because the new preview app is using Mapbox as a map provider instead of Leaflet and data is now loaded programmatically instead of just pasting the PNG links into the browser (which do not requite CORS headers). Anways.

I tried to set TC_ALLOWED_ORIGINS_TILES and can see that it gets included in the config at runtime, but somehow that did not help?

@j08lue j08lue added the question Further information is requested label Apr 23, 2021
@j08lue
Copy link
Collaborator Author

j08lue commented Apr 23, 2021

Never mind. It works with the env var. Maybe I had something cached somewhere or so.

@j08lue j08lue closed this as completed Apr 23, 2021
@dionhaefner
Copy link
Collaborator

Shouldn't we fix this for everyone by changing the default, then?

@j08lue
Copy link
Collaborator Author

j08lue commented Apr 26, 2021

Shouldn't we fix this for everyone by changing the default, then?

Yes! Do you mean the default for terracotta serve or the app in general?

We are mostly using Mapbox to load TC layers (sometimes with Deck.gl) these days, so we always need that. Others might not, of course... Hard to tell which is better. I would perhaps prefer to make * the default, then fewer people will encounter bumps.

@dionhaefner
Copy link
Collaborator

I mean adding localhost to allowed origins, so the use case terracotta serve && terracotta connect always works. I wouldn't allow all by default.

@j08lue
Copy link
Collaborator Author

j08lue commented Apr 26, 2021

I'll test whether localhost and/or 127.0.0.1 works, also in Chrome... https://stackoverflow.com/questions/10883211/why-does-my-http-localhost-cors-origin-not-work

@chapmanjacobd
Copy link
Contributor

yeah adding localhost by default makes a lot more sense than having no default since modern browsers seem to block localhost requests which have no CORS header set; at least in Firefox

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

No branches or pull requests

3 participants