Problem realated to ITK.JS WebWorkers/ImageIO.worker.js

Hello everyone,
I am trying to run the below code to read a series of DICOM images and convert them into VTK objects before I send them for visualization.
Problem is that, sometimes, itk.js read the image but most of the time I receive the below message about the CORE.POLICY. I tried both ways as follows to call itk.js to read images but still most of the time I receive the below error.

    <script src="https://unpkg.com/itk@14.0.1/umd/itk.js"></script>
<!--    <script type="text/javascript" src="{% static '/js/itk.js' %}"></script>-->

CODE:

function vol_processFile(vol_arrFileList, vol_color_val) {
  var vol_img  = []
  console.log(vol_arrFileList)
  const vol_files = vol_arrFileList

vol_prom = []

for ( l = 0 ; l < vol_files.length; l++){
    console.time('image_loading_Time');
    if (l  == 0){
        if (vol_files[l].length === 1) {
              vol_prom[l] = itk.readImageFile(null, vol_files[l][0])
              .then(function ({ webWorker, image: itkImage }) {
                webWorker.terminate()
                vol_imageData = convertItkToVtkImage(itkImage)
                console.log(vol_imageData)
                vol_img.push(vol_imageData)
              })
          } else {
           vol_prom[l] = itk.readImageDICOMFileSeries(vol_files[l]).then(function ({ image: itkImage }) {
            vol_imageData = convertItkToVtkImage(itkImage)
            console.log(vol_imageData)
             vol_img.push(vol_imageData)
              })
          }
        }
    else {
        if (vol_files[l].length === 1) {
              vol_prom[l] = itk.readImageFile(null, vol_files[l][0])
              .then(function ({ webWorker, image: itkImage }) {
                webWorker.terminate()
                vol_imageData = convertItkToVtkImage(itkImage)
                console.log(vol_imageData)
                 vol_img.push(vol_imageData)
              })
          } else {
            vol_prom[l] = itk.readImageDICOMFileSeries(vol_files[l]).then(function ({ image: itkImage }) {
                vol_imageData = convertItkToVtkImage(itkImage)
               // console.log(imageData)
                 vol_img.push(vol_imageData)
                  })
      }
    }
    setTimeout(function delay(){
      console.timeEnd('image_loading_Time');
    }, 1500);
}

Promise.all(vol_prom).then((values) => {
    console.log(vol_prom)

    $( "#btn2" ).prop( "disabled", true )
     $( "#f" ).prop( "disabled", true )
     $( ".colors_channels" ).prop( "disabled", true )
    //while(true){
    console.time('image_render_Time');
     volume_rendering(vol_img, vol_color_val) // Calls Volume rendering script
     // surface_rendering(img, color_val) // Calls surface rendering script
     // tri_planar_rendering(img) // Calls Tri-Planar rendering script
     // mpr_rendering(img) // Calls Multi-Planar Reconstruction rendering script

     console.log(vol_img.length +"  -  "+ vol_files.length)
     //if(img.length == files.length){
       // break;
     //}
    //}
        setTimeout(function delay(){
      console.timeEnd('image_render_Time');
    }, 1500);
}).catch(
console.log("Please check the input files again"));
//console.log(img)

}

ERROR:
Access to XMLHttpRequest at 'https://unpkg.com/itk@14.0.1/WebWorkers/ImageIO.worker.js' from origin '[http://127.0.0.1:8000](http://127.0.0.1:8000/)' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I have already installed the required Django core files on my PC and also did whatever they suggest to include in setting.py like below but I still receive this error.
ALLOWED_HOSTS = [‘*’]
CORS_ORIGIN_ALLOW_ALL = True #########################################################################
Is there a way to solve this problem permanently? I am trying to solve it for a long time. I think there is some problem while fetching itk.js from CDN.

@matt.mccormick might know.

Hi,

Please upgrade from itk-wasm, which has updated resource access and now uses jsdelivr instead of unpkg by default.