export default async function Home() {
const res = await method();
return <main></main>;
}
const method = async () => {
const { cookies } = await import("next/headers");
const value = cookies().get("some-cookie");
const res = await fetch("/somewhere", {
headers: {
Cookie: `${value}`,
},
});
// в res новые куки
//как добавить новые куки к ответу от сервера next????
return res;
};
我决定如下。
任何带有 401 的获取请求都会发送到路由,其中有一个单独的请求,该请求会更新后端上的几个令牌并重定向回请求所在的页面。