mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-28 15:01:17 -07:00
Fix: allow explicit cookie header overwrite (#6672)
Tests / vitest (1) (push) Has been cancelled
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import getServiceWidget from "utils/config/service-helpers";
|
||||
import createLogger from "utils/logger";
|
||||
import { asJson, formatApiCall, sanitizeErrorURL } from "utils/proxy/api-helpers";
|
||||
import { addCookieToJar } from "utils/proxy/cookie-jar";
|
||||
import { addCookieToJar, setCookieHeader } from "utils/proxy/cookie-jar";
|
||||
import { httpProxy } from "utils/proxy/http";
|
||||
import widgets from "widgets/widgets";
|
||||
|
||||
@@ -57,6 +57,7 @@ export default async function frigateProxyHandler(req, res, map) {
|
||||
}
|
||||
|
||||
addCookieToJar(url, loginResponseHeaders);
|
||||
setCookieHeader(url, params, { overwrite: true });
|
||||
// Retry original request with cookie set
|
||||
[status, , data] = await httpProxy(url, params);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ const { httpProxy, getServiceWidget, cookieJar, logger } = vi.hoisted(() => ({
|
||||
getServiceWidget: vi.fn(),
|
||||
cookieJar: {
|
||||
addCookieToJar: vi.fn(),
|
||||
setCookieHeader: vi.fn(),
|
||||
},
|
||||
logger: {
|
||||
debug: vi.fn(),
|
||||
@@ -130,6 +131,9 @@ describe("widgets/frigate/proxy", () => {
|
||||
await frigateProxyHandler(req, res);
|
||||
|
||||
expect(cookieJar.addCookieToJar).toHaveBeenCalled();
|
||||
expect(cookieJar.setCookieHeader).toHaveBeenCalledWith("http://frigate/api/stats", expect.any(Object), {
|
||||
overwrite: true,
|
||||
});
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toEqual({ num_cameras: 2, uptime: 123, version: "1.0" });
|
||||
});
|
||||
|
||||
@@ -86,6 +86,9 @@ describe("widgets/unifi/proxy", () => {
|
||||
expect(httpProxy).toHaveBeenCalledTimes(4);
|
||||
expect(httpProxy.mock.calls[1][0].toString()).toContain("/proxy/network/api/self");
|
||||
expect(cookieJar.addCookieToJar).toHaveBeenCalled();
|
||||
expect(cookieJar.setCookieHeader).toHaveBeenLastCalledWith(expect.any(URL), expect.any(Object), {
|
||||
overwrite: true,
|
||||
});
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toEqual(Buffer.from("data"));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user