Open eknowles opened 1 month ago
You can initialize a FetchSource
with CustomHeaders
:
https://protomaps.github.io/PMTiles/typedoc/classes/FetchSource.html
Thank you for the quick response, how would that work with addSource?
maplibre expects a string here both for tiles
and url
See this example: https://github.com/protomaps/PMTiles/blob/main/js/examples/maplibre.html#L26
You can then reference it in a style via the same Url and it will resolve to the same instance
new pmtiles.PMTiles(fetchSource)
When using a custom
maplibre.addSource
to use pmtiles, thePMTiles.getBytes
method uses the globalfetch
method, this is done during the read metadata stage I think.This means users can not alter the options such as setting credentials
https://github.com/protomaps/PMTiles/blob/main/js/index.ts#L379-L399
Once this has been read maplibre (i think) will then use the
loaders.gl
fetch methods which does allow the user to override this at a global level.https://loaders.gl/docs/modules/core/api-reference/fetch-file
Could the pmtiles protocol also use this method so that users can fetch pmtiles using cors + credentials?