我使用react js作为前端,spring引导用于后端进程。我需要将cookie从前端发送到后端,并尝试使用axios实现以下方法:
前端
async function submitPageData() {
try {
const jwttoken = {
headers: {
jwt: to12,
Cookie: token
}
};
const response = await axios
.put(
url,
{
id: pageId,
projectName: PROJECT_NAME,
title: title
},
jwttoken
)
.then(function () {
});
} catch (error) {
}
}
}
}并使用@CookieValue注释在后端接收Cookie,但当我检查并发现我的请求头没有携带Cookie时。
请指导我,如何从receive方法发送cookie,以便我能够在后端接收到它。
编辑
const jwttoken = {
headers: {
jwt: to12,
Cookie: token,
withCredentials: true
}提前感谢!
发布于 2019-12-27 12:06:55
由于某些原因,使用withCredentials作为标题对我也不起作用。
如下所示:
import axios from "axios";
axios.defaults.withCredentials = true;https://stackoverflow.com/questions/59499907
复制相似问题