I got Cross-Origin Request Blocked when importing external JS

Hi everyone, I am migrating some plugin from elgg 5 to elgg 6.

In my Bootstrap.php, I registered an ES Module this way.

elgg_register_esm('jitsi-external-api-js', 'https://meet.jit.si/external_api.js');

 

In my  .mjs file I imported the ES Module this way.

import 'jitsi-external-api-js';

 

But when open the page where the module is imported I got the following error.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://meet.jit.si/external_api.js. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.

Module source URI is not allowed in this document: “https://meet.jit.si/external_api.js”.

Could someone help me ?

When I loaded the same js (https://meet.jit.si/external_api.js) from elgg 5 it works perfectky.

 

 

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking