maptiler / tileserver-gl

Vector and raster maps with GL styles. Server side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.
https://tileserver.readthedocs.io/en/latest/
Other
2.24k stars 639 forks source link

CORS error using local server with mapbox-gl #292

Open CraigglesO opened 6 years ago

CraigglesO commented 6 years ago

Hey, currently using: tileserver-gl-light v2.3.1

currently if I use this:

"sources": {
    "openmaptiles": {
      "type": "vector",
      "url": "mbtiles://{v3}"
    },
    "parcel-lir": {
      "type": "vector",
      "url": "mbtiles://{parcel-lir}"
    }
  },

I get this error using mapbox-gl:

Failed to load mbtiles://{v3}: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
Failed to load mbtiles://{parcel-lir}: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

So then I figured i could so something like this:

"sources": {
    "openmaptiles": {
      "type": "vector",
      "url": "http://localhost/{v3}"
    },
    "parcel-lir": {
      "type": "vector",
      "url": "http://localhost/{parcel-lir}"
    }
  },

No avail. Any suggestions on how to still access the server but either equip cors or use http?

Thanks, Craig.

richardvil commented 4 years ago

Probably the problem isn't on tileserver-gl, check if the app that consume the tiles has CORS enable. I known that is an old question but better late than never.