Creating dynamic WebWorker ( Refused to execute script from because its MIME type ('text/html') )

Viewed 283

Have problem with webworker. Have this line for creating:

public dbWorker = new Worker(new URL('./workers/db-worker.worker', import.meta.url), { type: 'module' });

And get an error:

Refused to execute script from 'https://...worker.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Seems need to add type text/javascript but I'm not sure. Tried something like this, without successful:

// content = './workers/db-worker.worker';

// worker_url = URL.createObjectURL(new Blob([this.content], { type: "text/javascript" }));

// dbWorker = new Worker(this.worker_url, { type: 'module' });
0 Answers
Related