Hi, we’re using the Twitter for Websites JavaScript API, and are trying to import dynamically https://platform.twitter.com/widgets.js. The problem is that dynamic imports require CORS:

Access to script at ‘https://platform.twitter.com/widgets.js’ from origin ‘http://localhost:1234’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Can Twitter please set the appropriate headers? Thanks!

Hello @CryptoClimate,

Can you please provide the code & browser/version you’re using to try to dynamically import widgets.js so we can look into this further?

Thanks!

I’m using Chromium 71 (Firefox doesn’t support dynamic imports) and the code is simply

import('https://platform.twitter.com/widgets.js').then(() => console.log('import worked'));

Here’s a jsbin showing dynamic import working for jQuery and failing for the widget.js.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

Hi @CryptoClimate,

Can you try this now and let us know if you run into any other issues? The CORS issue should be resolved.

Thanks!