我正在发送
Set-Cookies
标头,但浏览器没有设置 cookies。
后端代码(Lambda):
import { verifyToken, createToken } from "/opt/auth.mjs";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import {
DynamoDBDocumentClient,
PutCommand,
GetCommand,
DeleteCommand,
UpdateCommand,
} from "@aws-sdk/lib-dynamodb";
const client = new DynamoDBClient({});
const dynamo = DynamoDBDocumentClient.from(client);
export const handler = async (event) => {
let body= "hello World"
let statusCode = 200;
const multiValueHeaders = {
"Content-Type": "application/json",
"Set-Cookie": [
'isLoggedin=true',
],
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*'
};
return {
body,
multiValueHeaders,
statusCode,
};
};
前端获取(Next.js 托管在 Vercel 上):
const response = await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
我尝试过的: