0.2 在线版本打通
This commit is contained in:
@@ -6,7 +6,18 @@ type RequestCookies = Awaited<ReturnType<typeof cookies>>;
|
||||
|
||||
const decodeValue = (value?: string) => {
|
||||
if (!value) return value;
|
||||
return value.startsWith("base64-") ? Buffer.from(value.slice(7), "base64").toString("utf8") : value;
|
||||
let v = value;
|
||||
// 说明:部分环境下 cookies() 读取到的值仍是 URL 编码(例如 %5B%22...%22%5D),
|
||||
// Supabase Auth Helpers 期望拿到可直接 JSON.parse 的字符串,因此这里做一次解码。
|
||||
// 若不是合法的 URL 编码字符串,decodeURIComponent 会抛错,我们直接兜底返回原值。
|
||||
if (v.includes("%")) {
|
||||
try {
|
||||
v = decodeURIComponent(v);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return v.startsWith("base64-") ? Buffer.from(v.slice(7), "base64").toString("utf8") : v;
|
||||
};
|
||||
|
||||
const encodeValue = (value: string) => {
|
||||
|
||||
Reference in New Issue
Block a user