Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.ts | vapid-helper.js | URL is not a constructor #907

Open
Izocel opened this issue Nov 23, 2024 · 1 comment
Open

Next.ts | vapid-helper.js | URL is not a constructor #907

Izocel opened this issue Nov 23, 2024 · 1 comment

Comments

@Izocel
Copy link

Izocel commented Nov 23, 2024

Any hints on how to resolve this ?

image

client-stack:

TypeError: URL is not a constructor
    at Object.validateSubject (vapid-helper.js:80:26)
    at push.[project]/node_modules/web-push/src/web-push-lib.js [app-client] (:3000/ecmascript).WebPushLib.setVapidDetails (https://localhost:3000/_next/static/chunks/node_modules_3bae01._.js:5643:17)
    at [project]/src/app/tools/WebPush.ts [app-client] (:3000/ecmascript) (https://localhost:3000/_next/static/chunks/src_98f639._.js:40:167)
    at dev-base.ts:205:21
    at runModuleExecutionHooks (dev-base.ts:264:5)
    at instantiateModule (dev-base.ts:203:5)
    at getOrInstantiateModuleFromParent (dev-base.ts:132:10)
    at esmImport (runtime-utils.ts:214:18)
    at [project]/src/app/_components/PushNotificationManager.tsx [app-client] (:3000/ecmascript) (https://localhost:3000/_next/static/chunks/src_98f639._.js:94:137)
    at dev-base.ts:205:21
    at runModuleExecutionHooks (dev-base.ts:264:5)
    at instantiateModule (dev-base.ts:203:5)
    at getOrInstantiateModuleFromParent (dev-base.ts:132:10)
    at commonJsRequire (runtime-utils.ts:241:18)
    at requireModule (react-server-dom-turbopack-client.browser.development.js:108:27)
    at initializeModuleChunk (react-server-dom-turbopack-client.browser.development.js:1051:21)
    at readChunk (react-server-dom-turbopack-client.browser.development.js:925:11)
    at react-stack-bottom-frame (react-dom-client.development.js:22442:18)
    at beginWork (react-dom-client.development.js:9582:24)
    at runWithFiberInDEV (react-dom-client.development.js:543:16)
    at performUnitOfWork (react-dom-client.development.js:14985:22)
    at workLoopConcurrent (react-dom-client.development.js:14979:9)
    at renderRootConcurrent (react-dom-client.development.js:14954:15)
    at performWorkOnRoot (react-dom-client.development.js:14286:11)
    at performWorkOnRootViaSchedulerTask (react-dom-client.development.js:15842:7)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:44:48)

Using the window API whould solve my case:

new window.URL(subject)
@aomi
Copy link

aomi commented Jan 21, 2025

Switching the underlying runtime to Node.js instead of Edge helped for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants