simonw / datasette-leaflet-geojson

Datasette plugin that replaces any GeoJSON column values with a Leaflet map.
19 stars 8 forks source link

Plugin broken because of a wrong mime type error #21

Open m0nac0 opened 11 months ago

m0nac0 commented 11 months ago

Hi, I'm trying to get to know some of your awesome plugins for datasette.

But when I try to use this plugin (or https://github.com/eyeseast/datasette-geojson-map) and run datasette locally, the maps never show up. I only see the error: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec. in the console. This happens with Firefox as well as with Chromium browsers.

m0nac0 commented 11 months ago

Fixed it temporarily by replacing this line: https://github.com/simonw/datasette/blob/452a587e236ef642cbc6ae345b58767ea8420cb5/datasette/utils/asgi.py#L296C17-L296C78

with "text/javascript" if str(filepath).endswith("js") else content_type or guess_type(str(filepath))[0] or "text/plain",