mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-11-22 14:33:10 -05:00
Fix bearer cookie being base64ed
This commit is contained in:
parent
572ddc69ad
commit
bc6c93c9c7
@ -10,7 +10,7 @@ const writeAccounts = (accounts: Account[]) => {
|
|||||||
if (!selected) return;
|
if (!selected) return;
|
||||||
setCookie("account", selected);
|
setCookie("account", selected);
|
||||||
// cookie used for images and videos since we can't add Authorization headers in img or video tags.
|
// cookie used for images and videos since we can't add Authorization headers in img or video tags.
|
||||||
setCookie("X-Bearer", selected?.token);
|
setCookie("X-Bearer", selected?.token, { skipBase64: true });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -15,8 +15,14 @@ function fromBase64(b64: string) {
|
|||||||
return Buffer.from(b64, "base64").toString("utf8");
|
return Buffer.from(b64, "base64").toString("utf8");
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setCookie = (key: string, val?: unknown) => {
|
export const setCookie = (
|
||||||
const value = toBase64(typeof val !== "string" ? JSON.stringify(val) : val);
|
key: string,
|
||||||
|
val?: unknown,
|
||||||
|
opts?: { skipBase64?: boolean },
|
||||||
|
) => {
|
||||||
|
const value = opts?.skipBase64
|
||||||
|
? val
|
||||||
|
: toBase64(typeof val !== "string" ? JSON.stringify(val) : val);
|
||||||
const d = new Date();
|
const d = new Date();
|
||||||
// A year
|
// A year
|
||||||
d.setTime(d.getTime() + 365 * 24 * 60 * 60 * 1000);
|
d.setTime(d.getTime() + 365 * 24 * 60 * 60 * 1000);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user