CORS error when importing Leaflet across notebooks

I have created a Leaflet map in one notebook and wish to show it in another notebook, which I presume should work by importing the cell. However, when I try, I get a TypeError: Failed to fetch dynamically imported module

Here’s a simple notebook trying to embed Tom’s Leaflet Map

My console throws a CORS error:
Access to script at 'https://observablehq.com/@tmcw/leaflet' from origin 'https://aaronkyle.static.observableusercontent.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Any idea why this is the case, and how to import Tom’s rendered map?

It’s an error I make very often too. You have to write

import { map } from "@tmcw/leaflet"

instead of

import { map } from "https://observablehq.com/@tmcw/leaflet"
1 Like

Thanks @severo!

This helped me realize that for a non-named / link-shared URL I can’t use the /d prefix or include / before the unique ID. I updated my notebook from my original question to show failing and working patterns.

1 Like