路由:/api/auth/login/route.ts
import {NextResponse} from "next/server";
// POST /api/auth/login
export async function POST(request: Request) {
const { account, password } = await request.json();
const res = await fetch('http://localhost:8081/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
account,
password,
}),
});
const data = await res.json();
const response = NextResponse.json(data);
response.cookies.set('token', data.data, {
httpOnly: true,
// secure: true,
// sameSite: 'strict',
maxAge: 86400
});
return response;
}
这样不对吗?就是没有值
找到了官方文档:https://nextjs.org/docs/app/building-your-application/data-fe...