Add /imaging route for avatar proxy and prevent redirect loops
Local Build and Deploy / deploy (push) Successful in 1m10s
Local Build and Deploy / deploy (push) Successful in 1m10s
This commit is contained in:
1 parent
169f658097
commit
71f154cf52
3 files changed
+116
-2
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -13,6 +13,10 @@ describe("resolveImagerBase", () => {
|
|||||||
expect(
|
expect(
|
||||||
resolveImagerBase("https://www.epicnabbo.nl/api/imaging/avatar"),
|
resolveImagerBase("https://www.epicnabbo.nl/api/imaging/avatar"),
|
||||||
).toBe(HABBO_IMAGER_URL);
|
).toBe(HABBO_IMAGER_URL);
|
||||||
|
expect(resolveImagerBase("/imaging")).toBe(HABBO_IMAGER_URL);
|
||||||
|
expect(
|
||||||
|
resolveImagerBase("https://www.epicnabbo.nl/imaging"),
|
||||||
|
).toBe(HABBO_IMAGER_URL);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps a custom Habbo-compatible base", () => {
|
it("keeps a custom Habbo-compatible base", () => {
|
||||||
|
|||||||
+2
-2
@@ -20,12 +20,12 @@ export const HABBO_IMAGER_URL =
|
|||||||
*/
|
*/
|
||||||
export function resolveImagerBase(configured?: string | null): string {
|
export function resolveImagerBase(configured?: string | null): string {
|
||||||
const fromEnv = process.env.NEXT_PUBLIC_IMAGER_URL?.trim();
|
const fromEnv = process.env.NEXT_PUBLIC_IMAGER_URL?.trim();
|
||||||
if (fromEnv && !fromEnv.includes("/api/imaging/avatar")) {
|
if (fromEnv && !fromEnv.includes("/api/imaging/avatar") && !fromEnv.includes("/imaging")) {
|
||||||
return fromEnv.replace(/\/+$/, "");
|
return fromEnv.replace(/\/+$/, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
const v = (configured ?? "").trim();
|
const v = (configured ?? "").trim();
|
||||||
if (!v || v.includes("/api/imaging/avatar")) {
|
if (!v || v.includes("/api/imaging/avatar") || v.includes("/imaging")) {
|
||||||
return HABBO_IMAGER_URL;
|
return HABBO_IMAGER_URL;
|
||||||
}
|
}
|
||||||
return v.replace(/\/+$/, "");
|
return v.replace(/\/+$/, "");
|
||||||
|
|||||||
Reference in new issue
Block a user