Production-ready wiring: VAPID prop fix, port mappings, AUTH_URL
- PushOptIn now accepts vapidKey as a prop from its server-component parent (settings page reads VAPID_PUBLIC_KEY at runtime) — eliminates the NEXT_PUBLIC_* build-time dependency so pre-built GHCR images work without a build arg. - deploy/compose.yaml: famapp exposes 3010:3000, authentik-server exposes 9200:9000 so the existing Caddy stack can proxy by IP, matching every other service in the homelab. NEXT_PUBLIC_APP_URL replaced by AUTH_URL (correct next-auth v5 var). - deploy/Caddyfile.snippet: updated to 192.168.1.69:3010 / :9200. - .env.production.example: AUTH_URL, ntfy pre-wired to ntfy.ginnoir.com, VAPID_SUBJECT prefilled with real email. - typecheck and pnpm build both pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
c73338e256
commit
1185f5ab50
@@ -8,8 +8,6 @@ import {
|
||||
sendTestNotification,
|
||||
} from "@/app/settings/push-actions";
|
||||
|
||||
const VAPID_KEY = process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY ?? "";
|
||||
|
||||
function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer> {
|
||||
const padding = "=".repeat((4 - (base64String.length % 4)) % 4);
|
||||
const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
|
||||
@@ -19,13 +17,13 @@ function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer> {
|
||||
return buf;
|
||||
}
|
||||
|
||||
export function PushOptIn() {
|
||||
export function PushOptIn({ vapidKey }: { vapidKey: string }) {
|
||||
const [status, setStatus] = useState<"idle" | "subscribed" | "denied" | "unsupported">("idle");
|
||||
const [endpoint, setEndpoint] = useState<string | null>(null);
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const [testSent, setTestSent] = useState(false);
|
||||
|
||||
if (!VAPID_KEY) return null;
|
||||
if (!vapidKey) return null;
|
||||
if (!("serviceWorker" in navigator) || !("PushManager" in window)) {
|
||||
return (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
@@ -39,7 +37,7 @@ export function PushOptIn() {
|
||||
const registration = await navigator.serviceWorker.ready;
|
||||
const sub = await registration.pushManager.subscribe({
|
||||
userVisibleOnly: true,
|
||||
applicationServerKey: urlBase64ToUint8Array(VAPID_KEY),
|
||||
applicationServerKey: urlBase64ToUint8Array(vapidKey),
|
||||
});
|
||||
const json = sub.toJSON() as { endpoint: string; keys: { p256dh: string; auth: string } };
|
||||
startTransition(async () => {
|
||||
|
||||
Reference in New Issue
Block a user