friendlyeats-web icon indicating copy to clipboard operation
friendlyeats-web copied to clipboard

auth-service-worker.js not found

Open minhdanh opened this issue 1 year ago • 4 comments

I'm seeing this error when running nextjs-end:

Unhandled Runtime Error
TypeError: Failed to register a ServiceWorker for scope ('http://localhost:3000/') with script ('http://localhost:3000/auth-service-worker.js?firebaseConfig=[filtered]'): A bad HTTP response code (404) was received when fetching the script.
image

I inspected the network call and could see the request for auth-service-worker.js returned 404.

minhdanh avatar Jun 07 '24 22:06 minhdanh

If I move the file auth-service-worker.js to /public and refresh, then I see another error:

TypeError: Failed to register a ServiceWorker for scope ('http://localhost:3000/') with script ('http://localhost:3000/auth-service-worker.js?firebaseConfig=[filtered]'): ServiceWorker script evaluation failed

minhdanh avatar Jun 07 '24 22:06 minhdanh

If you look in the package.json you'll see there's an extra build-service-worker task in the scripts block. This is called by the build task and is what packages auth-service-worker.js up and makes it available in the public folder. You'll need to npm install esbuild for this to work.

rlw87 avatar Jun 08 '24 22:06 rlw87

did anyone find the solution to this?

t77bsh avatar Jun 28 '24 16:06 t77bsh

As @rlw87 mentioned, you have to run the build-service-worker script and then it appears to work.

npm run build-service-worker

Hope that helps.

heckchuckman avatar Jul 21 '24 16:07 heckchuckman