Make imager URL absolute using NEXT_PUBLIC_APP_URL to avoid port issues
Local Build and Deploy / deploy (push) Successful in 53s
Local Build and Deploy / deploy (push) Successful in 53s
This commit is contained in:
1 parent
a5e085e04c
commit
ddb7e77877
5 files changed
+44
-12
No files matched your search
+9
-3
@@ -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(/\/+$/, "");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user