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

KML NetworkLink CORS Issue #8381

Closed
gogo1211 opened this issue Nov 10, 2019 · 3 comments
Closed

KML NetworkLink CORS Issue #8381

gogo1211 opened this issue Nov 10, 2019 · 3 comments

Comments

@gogo1211
Copy link

Hello, guys.

I was trying to add KML to cesium map using KmlDataSource.
But I am getting the following error on console.

Access to XMLHttpRequest at 'http://alphaalpha.ddns.net:4181/pp_google.kml' from origin 'http://localhost:3001' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

This is the content of KML file.
<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.0"> <Document> <visibility>1</visibility> <NetworkLink> <name>PP1</name> <flyToView>0</flyToView> <Url><href>http://alphaalpha.ddns.net:4181/pp_google.kml</href> <refreshMode>onInterval</refreshMode> <refreshInterval>4</refreshInterval> <viewRefreshMode>never</viewRefreshMode> </Url> <refreshVisibility>1</refreshVisibility> </NetworkLink> </Document> </kml>

@gogo1211 gogo1211 mentioned this issue Nov 10, 2019
76 tasks
@hpinkos
Copy link
Contributor

hpinkos commented Nov 11, 2019

Hello @gogo1211, the site serving your KML file will need to enable CORS. If you don't have control over that site, i would recommend trying to contact the site owner. You can find resources to learn more about CORS here: https://enable-cors.org/

@hpinkos hpinkos closed this as completed Nov 11, 2019
@thw0rted
Copy link
Contributor

For local testing (the error shows your Origin as being localhost) I suggest running your site in a browser with CORS protections disabled. I believe Firefox may have extensions that facilitate this. I use Chrome with the arguments

                "--allow-file-access-from-files",
                "--disable-web-security",
                "--disable-session-crashed-bubble",
                "--disable-infobars",
                "--user-data-dir=${workspaceRoot}/tmp/chromium",
                "http://localhost:8080/?debug=true"

You can probably get away with just --disable-web-security --user-data-dir=/path/to/some/profile, which removes CORS protections and points the browser to a non-standard profile location, so that you won't accidentally have active login sessions with your bank / email / whatever.

@gogo1211
Copy link
Author

@hpinkos , @thw0rted , thank you!

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