mapbox / mapboxgl-jupyter

Use Mapbox GL JS to visualize data in a Python Jupyter notebook
MIT License
668 stars 137 forks source link

Examples don't work as shown, due to Jupyter "Blocking request with no referer" #165

Closed maciejb closed 5 years ago

maciejb commented 5 years ago

I tried running the examples as shown in the docs, e.g. the CircleViz in the README, and the result is a blank map (tiles but no markers).

Looking at the Jupyter logs:

[I 17:19:42.806 NotebookApp] 302 GET /notebooks/points.geojson (::1) 1.54ms
[W 17:19:42.821 NotebookApp] Blocking request with no referer
[W 17:19:42.822 NotebookApp] 403 GET /files/points.geojson (::1): Blocking request from unknown origin
[W 17:19:42.824 NotebookApp] 403 GET /files/points.geojson (::1) 2.88ms referer=None

This can easily be worked around by storing the df_to_geojson() to a variable instead of a file, and reading that variable when creating the viz.

Tried with a few different browsers and both a local and remote notebook server. Is this an issue that can be resolved in the mapboxgl module, or should the documentation be changed?

ryanbaumann commented 5 years ago

We should update the documentation to use an in-memory variable assignment as opposed to a flat file export. The web servers that run various Jupyter environments have various configurations (cors settings, relative file paths, etc) that can cause issues with referencing a locally exported file.

Thanks for flagging this @maciejb

almo-ltoeroek commented 5 years ago

same here

ryanrolds commented 5 years ago

Encountering this too, I was only able to get it to work with c.NotebookApp.disable_check_xsrf = True, which is not recommended for security reasons.

nygeog commented 5 years ago

Launching notebook jupyter notebook --NotebookApp.disable_check_xsrf=True also worked for me.

ryanbaumann commented 5 years ago

Closed with PR #170 - will roll into a new release in the next week.