Errors loading Dotlottie-player: access to script blocked by CORS / failed to load module script

Hello everyone,

I cannot get my Dotlottie player to work. I tried two methods.

Method 1:
I get these errors:
-Access to script at ‘https://unpkg.com/@dotlottie/player-component@latest/dist/dotlottie-player.mjs’ from origin ‘http://localhost:8888’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
-GET […same url as in error above…] net::ERR_FAILED 520

My code:

Method 2
After this I installed dotlottieplayer via npm in the terminal. I imported the script:

And included it in my main.js file:
import ‘@dotlottie/player-component’;

Then i get this 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.

What am I doing wrong here?

Thanks in advance for any advice!

(p.s. I could not paste all the urls in this post because I was not allowed to post more than two urls as a new user…)

Hi Eric,

We’re getting the same CORS Policy error on a live site that was working yesterday.

I hope it’s a temporary issue with unpkg.com, but I’m surprised more people aren’t flagging it as a problem.

1 Like

It’s back up and working now — is it working for you too?

Yes, working again! I also think it probably was something with unpkg. I guess I should install the dotlottie player locally to prevent this in the future…