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:
ginnoir
2026-05-06 18:32:08 -05:00
co-authored by Claude Sonnet 4.6
parent c73338e256
commit 1185f5ab50
6 changed files with 25 additions and 19 deletions
+2 -1
View File
@@ -14,6 +14,7 @@ export default async function SettingsPage() {
const { user } = await getCurrentSession();
const shareLinks = await getActiveShareLinks();
const ntfyConfigured = !!(process.env["NTFY_URL"] && process.env["NTFY_TOPIC"]);
const vapidKey = process.env["VAPID_PUBLIC_KEY"] ?? "";
return (
<div className="container max-w-2xl py-8 space-y-6">
@@ -46,7 +47,7 @@ export default async function SettingsPage() {
<CardTitle>Push Notifications</CardTitle>
</CardHeader>
<CardContent>
<PushOptIn />
<PushOptIn vapidKey={vapidKey} />
</CardContent>
</Card>
+3 -5
View File
@@ -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 () => {