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
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user