Repository: next.js
Issue: Error: Automatic publicPath is not supported in this browser
Labels: bug,Webpack

### Link to the code that reproduces this issue

https://github.com/kyledecot/next-worker-bug

### To Reproduce

1. Clone https://github.com/kyledecot/next-worker-bug
2. Run the commands in the README
3. Open http://localhost:3000

### Current vs. Expected behavior

Currently you'll receive the following error in the terminal:

```
 ⨯ ../worker/lib/index.js (1:1323) @ eval
 ⨯ Error: Automatic publicPath is not supported in this browser
    at eval (../worker/lib/index.js:51:27)
    at eval (../worker/lib/index.js:53:11)
    at eval (../worker/lib/index.js:67:7)
    at eval (../worker/lib/index.js:3:32)
    at eval (../worker/lib/index.js:5:2)
    at (ssr)/../worker/lib/index.js (/Users/tabulous-xyz/Desktop/example/app/.next/server/app/page.js:173:1)
    at __webpack_require__ (/Users/tabulous-xyz/Desktop/example/app/.next/server/webpack-runtime.js:33:42)
    at eval (./src/app/page.tsx:7:64)
    at (ssr)/./src/app/page.tsx (/Users/tabulous-xyz/Desktop/example/app/.next/server/app/page.js:162:1)
    at Object.__webpack_require__ [as require] (/Users/tabulous-xyz/Desktop/example/app/.next/server/webpack-runtime.js:33:42)
    at JSON.parse (<anonymous>)
digest: "533203242"
> 1 | !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["react"],t);else{var r="object"==typeof exports?t(require("react")):t(e.react);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{"use strict";var t={155:t=>{t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.m=t,o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.u=e=>e+".index.js",o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),o.b=document.baseURI||self.location.href;var n={};o.r(n),o.d(n,{WorkerComponent:()=>c,default:()=>a});var i=o(155);const c=()=>{const e=(0,i.useRef)();return(0,i.useEffect)((()=>{e.current=new Worker(new URL(o.p+o.u(396),o.b))}),[]),null},a=c;return n})()));
    |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ^
 GET / 500 in 1587ms
```

### Provide environment information

```bash
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 20.11.1
  npm: 10.1.0
  Yarn: 1.22.19
  pnpm: N/A
Relevant Packages:
  next: 14.2.5 // Latest available version is detected (14.2.5).
  eslint-config-next: 14.2.5
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.5.3
Next.js Config:
  output: N/A
```


### Which area(s) are affected? (Select all that apply)

Webpack

### Which stage(s) are affected? (Select all that apply)

next dev (local)

### Additional context

_No response_