From a16921f2648891afc84191637a4c520b37e00af8 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Tue, 20 May 2025 00:25:28 +0200 Subject: [PATCH] Read vapid subject from the environment Load the contact details for push notifications from the NUXT_VAPID_SUBJECT environment variable. --- nuxt.config.ts | 1 + server/web-push.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index 69fc68d..0b9f795 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -4,6 +4,7 @@ export default defineNuxtConfig({ devtools: { enabled: true }, runtimeConfig: { cookieSecretKey: "", + vapidSubject: "", vapidPrivateKey: "", public: { defaultTimezone: "Europe/Oslo", diff --git a/server/web-push.ts b/server/web-push.ts index 2dd9bc8..c4c4f07 100644 --- a/server/web-push.ts +++ b/server/web-push.ts @@ -14,11 +14,12 @@ function useVapidDetails(event: H3Event) { } const runtimeConfig = useRuntimeConfig(event); + if (!runtimeConfig.vapidSubject) throw new Error("NUXT_VAPID_SUBJECT not set.") if (!runtimeConfig.public.vapidPublicKey) throw new Error("NUXT_PUBLIC_VAPID_PUBLIC_KEY not set.") if (!runtimeConfig.vapidPrivateKey) throw new Error("NUXT_VAPID_PRIVATE_KEY not set.") return cachedVapidDetails = { - subject: "mailto:webmaster@hornwitser.no", + subject: runtimeConfig.vapidSubject, publicKey: runtimeConfig.public.vapidPublicKey, privateKey: runtimeConfig.vapidPrivateKey, }