new WebWorker + assetPrefix = 🤯
Unanswered
American posted this in #help-forum
AmericanOP
Hello!
I'm trying to load a webworker, like this:
I'm also using an
I'm trying to load a webworker, like this:
workerRef.current = new Worker(
new URL("../../transformers/transformers.worker.ts", import.meta.url),
);I'm also using an
assetPrefix. I get this error:SyntaxError: WorkerGlobalScope.importScripts: Failed to load worker script at "http://localhost:3000http://localhost:3030/_next/static/chunks/66c92_onnxruntime-web_dist_33c4af75._.js" e43b0848-5ae9-40d0-ad50-89a8ed94ce83:11:14http://localhost:3000 = dev serverhttp://localhost:3030 = asset prefix7 Replies
European Turtle-Dove
This happens because when u use assetPrefix, the Worker URL gets resolved incorrectly your code is prepending the dev server URL and the assetPrefix resulting in a malformed double URL
AmericanOP
Yes, so is it a bug?
@American Yes, so is it a bug?
European Turtle-Dove
@American DM me
@European Turtle-Dove <@131748314256244736> DM me
AmericanOP
Why not take it here? So other people can find the solution too
@American Why not take it here? So other people can find the solution too
European Turtle-Dove
sure
please use the public/ folder for the worker and load it with the asset prefix
or remove assetPrefix in dev in next.config.js