From ddb7e77877d3a00054aedd0f3e973ae24f644c89 Mon Sep 17 00:00:00 2001 From: openhands Date: Wed, 15 Jul 2026 22:45:35 +0200 Subject: [PATCH] Make imager URL absolute using NEXT_PUBLIC_APP_URL to avoid port issues --- .env.example | 3 ++- src/lib/imager.test.ts | 15 +++++++-------- src/lib/imager.ts | 12 +++++++++--- storage/logs/email-2026-07-07T19-45-53-334Z.html | 13 +++++++++++++ storage/logs/email-2026-07-12T23-06-18-058Z.html | 13 +++++++++++++ 5 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 storage/logs/email-2026-07-07T19-45-53-334Z.html create mode 100644 storage/logs/email-2026-07-12T23-06-18-058Z.html diff --git a/.env.example b/.env.example index 025d42e9..5e3e8873 100644 --- a/.env.example +++ b/.env.example @@ -11,6 +11,7 @@ DATABASE_CONNECT_TIMEOUT_MS=10000 # Used by SSO ticket generation ({HOTEL_NAME}-{uuid}) HOTEL_NAME=Atom APP_URL=http://localhost:3000 +# NEXT_PUBLIC_APP_URL=https://yourdomain.com AUTH_URL=http://localhost:3000 # NextAuth (>=32 chars) + Laravel APP_KEY (base64:...) for existing 2FA secrets @@ -39,7 +40,7 @@ RCON_HOST=127.0.0.1 RCON_PORT=3001 # Public imager URL — overrides the default /imaging relative path. -# Set to an absolute URL when the proxy runs on a different origin/port. +# Falls back to NEXT_PUBLIC_APP_URL/imaging when only the app URL is set. # NEXT_PUBLIC_IMAGER_URL=https://epicnabbo.nl/imaging # Optional OAuth (enabled when both id+secret are set) diff --git a/src/lib/imager.test.ts b/src/lib/imager.test.ts index 83380f1b..fdb9dff0 100644 --- a/src/lib/imager.test.ts +++ b/src/lib/imager.test.ts @@ -1,23 +1,22 @@ import { describe, expect, it } from "vitest"; import { getAvatarUrl, - DEFAULT_IMAGER_URL, resolveImagerBase, resolveUpstreamBase, } from "./imager"; describe("resolveImagerBase", () => { - it("defaults to the site's own /imaging endpoint", () => { - expect(resolveImagerBase()).toBe(DEFAULT_IMAGER_URL); - expect(resolveImagerBase("")).toBe(DEFAULT_IMAGER_URL); - expect(resolveImagerBase(null)).toBe(DEFAULT_IMAGER_URL); + it("defaults to /imaging when no public URL env is set", () => { + expect(resolveImagerBase()).toBe("/imaging"); + expect(resolveImagerBase("")).toBe("/imaging"); + expect(resolveImagerBase(null)).toBe("/imaging"); }); it("rejects the broken self-hosted proxy", () => { - expect(resolveImagerBase("/api/imaging/avatar")).toBe(DEFAULT_IMAGER_URL); + expect(resolveImagerBase("/api/imaging/avatar")).toBe("/imaging"); expect( resolveImagerBase("https://www.epicnabbo.nl/api/imaging/avatar"), - ).toBe(DEFAULT_IMAGER_URL); + ).toBe("/imaging"); }); it("accepts /imaging as a valid configured URL", () => { @@ -45,7 +44,7 @@ describe("getAvatarUrl", () => { headOnly: true, direction: 2, }); - expect(url.startsWith(`${DEFAULT_IMAGER_URL}?`)).toBe(true); + expect(url.startsWith("/imaging?")).toBe(true); expect(url).toContain("figure=hr-115-42.hd-180-1"); expect(url).toContain("size=l"); expect(url).toContain("headonly=1"); diff --git a/src/lib/imager.ts b/src/lib/imager.ts index 5f8c3d14..1ec9fd22 100644 --- a/src/lib/imager.ts +++ b/src/lib/imager.ts @@ -10,8 +10,14 @@ export type { AvatarOptions } from "@/types/admin"; import type { AvatarOptions } from "@/types/admin"; -/** Default public imager endpoint (relative — served by the site itself). */ -export const DEFAULT_IMAGER_URL = "/imaging"; +/** Build an absolute default imager URL from public env vars. */ +function defaultImagerUrl(): string { + const pub = process.env.NEXT_PUBLIC_IMAGER_URL?.trim(); + if (pub && !pub.includes("/api/imaging/avatar")) return pub.replace(/\/+$/, ""); + const app = process.env.NEXT_PUBLIC_APP_URL?.trim(); + if (app) return `${app.replace(/\/+$/, "")}/imaging`; + return "/imaging"; +} /** * Resolve the public-facing imager base URL. @@ -25,7 +31,7 @@ export function resolveImagerBase(configured?: string | null): string { const v = (configured ?? "").trim(); if (!v || v.includes("/api/imaging/avatar")) { - return DEFAULT_IMAGER_URL; + return defaultImagerUrl(); } return v.replace(/\/+$/, ""); } diff --git a/storage/logs/email-2026-07-07T19-45-53-334Z.html b/storage/logs/email-2026-07-07T19-45-53-334Z.html new file mode 100644 index 00000000..8fd70ceb --- /dev/null +++ b/storage/logs/email-2026-07-07T19-45-53-334Z.html @@ -0,0 +1,13 @@ + +
+

Verify your email

+

Welcome to Epicnabbo! Confirm this email address to finish setting up your account.

+

+ + Verify email + +

+

If the button doesn't work, paste this link into your browser:

+

https://epicnabbo.nl/verify?token=5e21ef6e09952e9bb7257d54c1fe896713c0f05e6d92a1f8669869d875ab2693&email=juanedavid%40hotmail.com

+
\ No newline at end of file diff --git a/storage/logs/email-2026-07-12T23-06-18-058Z.html b/storage/logs/email-2026-07-12T23-06-18-058Z.html new file mode 100644 index 00000000..c303f8f5 --- /dev/null +++ b/storage/logs/email-2026-07-12T23-06-18-058Z.html @@ -0,0 +1,13 @@ + +
+

Verify your email

+

Welcome to Epicnabbo! Confirm this email address to finish setting up your account.

+

+ + Verify email + +

+

If the button doesn't work, paste this link into your browser:

+

https://epicnabbo.nl/verify?token=912723a081a705ccc4ee2871952bc96c4dbcd8072be497f04415f8ce298bd265&email=pirujina69%40hotmail.com

+
\ No newline at end of file