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;
|
||||
setCookie("account", selected);
|
||||
// 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");
|
||||
}
|
||||
|
||||
export const setCookie = (key: string, val?: unknown) => {
|
||||
const value = toBase64(typeof val !== "string" ? JSON.stringify(val) : val);
|
||||
export const setCookie = (
|
||||
key: string,
|
||||
val?: unknown,
|
||||
opts?: { skipBase64?: boolean },
|
||||
) => {
|
||||
const value = opts?.skipBase64
|
||||
? val
|
||||
: toBase64(typeof val !== "string" ? JSON.stringify(val) : val);
|
||||
const d = new Date();
|
||||
// A year
|
||||
d.setTime(d.getTime() + 365 * 24 * 60 * 60 * 1000);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user