Make imager URL absolute using NEXT_PUBLIC_APP_URL to avoid port issues
Local Build and Deploy / deploy (push) Successful in 53s

This commit is contained in:
openhands committed 2026-07-15 22:45:35 +02:00
1 parent a5e085e04c
commit ddb7e77877
5 files changed
+44 -12

No files matched your search

+2 -1
View File
@@ -11,6 +11,7 @@ DATABASE_CONNECT_TIMEOUT_MS=10000
# Used by SSO ticket generation ({HOTEL_NAME}-{uuid}) # Used by SSO ticket generation ({HOTEL_NAME}-{uuid})
HOTEL_NAME=Atom HOTEL_NAME=Atom
APP_URL=http://localhost:3000 APP_URL=http://localhost:3000
# NEXT_PUBLIC_APP_URL=https://yourdomain.com
AUTH_URL=http://localhost:3000 AUTH_URL=http://localhost:3000
# NextAuth (>=32 chars) + Laravel APP_KEY (base64:...) for existing 2FA secrets # NextAuth (>=32 chars) + Laravel APP_KEY (base64:...) for existing 2FA secrets
@@ -39,7 +40,7 @@ RCON_HOST=127.0.0.1
RCON_PORT=3001 RCON_PORT=3001
# Public imager URL — overrides the default /imaging relative path. # 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 # NEXT_PUBLIC_IMAGER_URL=https://epicnabbo.nl/imaging
# Optional OAuth (enabled when both id+secret are set) # Optional OAuth (enabled when both id+secret are set)
+7 -8
View File
@@ -1,23 +1,22 @@
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
import { import {
getAvatarUrl, getAvatarUrl,
DEFAULT_IMAGER_URL,
resolveImagerBase, resolveImagerBase,
resolveUpstreamBase, resolveUpstreamBase,
} from "./imager"; } from "./imager";
describe("resolveImagerBase", () => { describe("resolveImagerBase", () => {
it("defaults to the site's own /imaging endpoint", () => { it("defaults to /imaging when no public URL env is set", () => {
expect(resolveImagerBase()).toBe(DEFAULT_IMAGER_URL); expect(resolveImagerBase()).toBe("/imaging");
expect(resolveImagerBase("")).toBe(DEFAULT_IMAGER_URL); expect(resolveImagerBase("")).toBe("/imaging");
expect(resolveImagerBase(null)).toBe(DEFAULT_IMAGER_URL); expect(resolveImagerBase(null)).toBe("/imaging");
}); });
it("rejects the broken self-hosted proxy", () => { it("rejects the broken self-hosted proxy", () => {
expect(resolveImagerBase("/api/imaging/avatar")).toBe(DEFAULT_IMAGER_URL); expect(resolveImagerBase("/api/imaging/avatar")).toBe("/imaging");
expect( expect(
resolveImagerBase("https://www.epicnabbo.nl/api/imaging/avatar"), resolveImagerBase("https://www.epicnabbo.nl/api/imaging/avatar"),
).toBe(DEFAULT_IMAGER_URL); ).toBe("/imaging");
}); });
it("accepts /imaging as a valid configured URL", () => { it("accepts /imaging as a valid configured URL", () => {
@@ -45,7 +44,7 @@ describe("getAvatarUrl", () => {
headOnly: true, headOnly: true,
direction: 2, 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("figure=hr-115-42.hd-180-1");
expect(url).toContain("size=l"); expect(url).toContain("size=l");
expect(url).toContain("headonly=1"); expect(url).toContain("headonly=1");
+9 -3
View File
@@ -10,8 +10,14 @@ export type { AvatarOptions } from "@/types/admin";
import type { AvatarOptions } from "@/types/admin"; import type { AvatarOptions } from "@/types/admin";
/** Default public imager endpoint (relative — served by the site itself). */ /** Build an absolute default imager URL from public env vars. */
export const DEFAULT_IMAGER_URL = "/imaging"; 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. * Resolve the public-facing imager base URL.
@@ -25,7 +31,7 @@ export function resolveImagerBase(configured?: string | null): string {
const v = (configured ?? "").trim(); const v = (configured ?? "").trim();
if (!v || v.includes("/api/imaging/avatar")) { if (!v || v.includes("/api/imaging/avatar")) {
return DEFAULT_IMAGER_URL; return defaultImagerUrl();
} }
return v.replace(/\/+$/, ""); return v.replace(/\/+$/, "");
} }
@@ -0,0 +1,13 @@
<!-- To: [email protected] | From: | Subject: Verify your email · Epicnabbo -->
<div style="font-family:sans-serif;line-height:1.5;color:#0f172a">
<h2 style="margin:0 0 0.5rem">Verify your email</h2>
<p>Welcome to Epicnabbo! Confirm this email address to finish setting up your account.</p>
<p style="margin:1.25rem 0">
<a href="https://epicnabbo.nl/verify?token=5e21ef6e09952e9bb7257d54c1fe896713c0f05e6d92a1f8669869d875ab2693&email=juanedavid%40hotmail.com"
style="display:inline-block;padding:0.6rem 1.2rem;border-radius:8px;background:#eeb425;color:#1a1a2e;font-weight:700;text-decoration:none">
Verify email
</a>
</p>
<p style="color:#64748b;font-size:0.875rem">If the button doesn't work, paste this link into your browser:</p>
<p style="color:#64748b;font-size:0.875rem;word-break:break-all">https://epicnabbo.nl/verify?token=5e21ef6e09952e9bb7257d54c1fe896713c0f05e6d92a1f8669869d875ab2693&email=juanedavid%40hotmail.com</p>
</div>
@@ -0,0 +1,13 @@
<!-- To: [email protected] | From: | Subject: Verify your email · Epicnabbo -->
<div style="font-family:sans-serif;line-height:1.5;color:#0f172a">
<h2 style="margin:0 0 0.5rem">Verify your email</h2>
<p>Welcome to Epicnabbo! Confirm this email address to finish setting up your account.</p>
<p style="margin:1.25rem 0">
<a href="https://epicnabbo.nl/verify?token=912723a081a705ccc4ee2871952bc96c4dbcd8072be497f04415f8ce298bd265&email=pirujina69%40hotmail.com"
style="display:inline-block;padding:0.6rem 1.2rem;border-radius:8px;background:#eeb425;color:#1a1a2e;font-weight:700;text-decoration:none">
Verify email
</a>
</p>
<p style="color:#64748b;font-size:0.875rem">If the button doesn't work, paste this link into your browser:</p>
<p style="color:#64748b;font-size:0.875rem;word-break:break-all">https://epicnabbo.nl/verify?token=912723a081a705ccc4ee2871952bc96c4dbcd8072be497f04415f8ce298bd265&email=pirujina69%40hotmail.com</p>
</div>