Jan 30, 2026
0
Level 6
Is there a way to use web worker that is not in public?
I'm using Laravel v12, Vue3, inertiajs, Vite, Sail.
I tried importing;
import myWorker from "@/workers/worker?worker";
const testingFunc = () => {
const worker = new myWorker();
}
Where @ is resources/js/ but Firefox spits this message out:
Security Error: Content at http://localhost/testing-worker may not load data from http://[::1]:5174/resources/js/workers/worker.js?worker_file&type=module.
I also tried it on chromium's:
Uncaught SecurityError: Failed to construct 'Worker': Script at 'http://[::1]:5174/resources/js/workers/worker.js?worker_file&type=module' cannot be accessed from origin 'http://localhost'.
Putting the worker in /public folder makes it work, but is there a way to put it in /resources/js?
Please or to participate in this conversation.