-
-
Notifications
You must be signed in to change notification settings - Fork 772
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 issue when loading raster tiles via file protocol #3699
Comments
Isn't this a duplicate of #3680? |
Not sure if the root cause is the same, I'm not too much into the maplibre codebase. In #3680 it's about vector tiles, in my case it's about raster tiles. @HarelM: I've added a minimal reproduction to the description |
How did you test the fix? Did you build the version locally? |
Exactly. |
I also agree that this is a browser security limitation. I'm not too familiar with maplibre and all the settings. Maybe there are specific headers missing? |
I'm not too familiar with open layers but IIRC open layers are using html img elements while maplibre is using the webgl canvas and GPU and these have different permission when it comes to raster images. |
i would say this is a cantfix since file:// doesn't allow CORS headers and browser security requires them for canvas access. it might be possible to start the browser with options/flags to ignore those security settings. |
If you only have a small amount of data like a few megabytes of raster tiles, then you might be able to use |
I made a small demo with addProtocol and base64 encoded a tile here: https://jsbin.com/bobifok/edit?html,output |
User Story
As a user I can open an index.html file locally via the file protocol so that webp image tiles are loaded correctly.
Rationale
To give a bit of a context: Our WebApp can be downloaded as backup. The backup can be run locally without any server (just by opening the index.html). This works by intercepting all network requests. We generate the webp image tiles by ourselves and include it in our backup. However with mapLibre we couldn't figure out how to work around the CORS issues. XHR requests via the file protocol are not working, due to CORS limitations. The only solution would be to work with HTML image tags, but this is not supported by mapLibre (I think openLayers does it this way).
Is there any known workaround?
Impact
We can't integrate the maps in our backups, which leads to an inconsistent state.
EDIT: Added a minimal reproduction example:
reproduction.zip
openlayers-example.zip
The text was updated successfully, but these errors were encountered: