fix(server): 修复物品发送接口的跨域问题
- 在角色路由中添加了自定义请求头,以解决跨域问题 - 移除了前端的多余日志输出
This commit is contained in:
@@ -28,7 +28,21 @@ router.post("/item/send", async (req, res) => {
|
||||
const roleId = await query(`SELECT id FROM role where name = '${roleName}' limit 1`);
|
||||
if (roleId?.length != 1) res.json({ code: 1, msg: "没有找到角色" });
|
||||
const role = roleId[0].id;
|
||||
const result = await axios.post("http://192.168.25.110:19000/center/gm", { role, item: [itemId, itemNum] });
|
||||
const result = await axios.post(
|
||||
"http://192.168.25.110:19000/center/gm",
|
||||
{ role, item: [itemId, itemNum] },
|
||||
{
|
||||
headers: {
|
||||
Accept: "application/json, text/plain, */*",
|
||||
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
|
||||
Connection: "keep-alive",
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/121.0.0.0",
|
||||
"Accept-Encoding": "gzip",
|
||||
"X-Mgip-sign": "gzip",
|
||||
},
|
||||
}
|
||||
);
|
||||
console.log("物品[%s]发送给[%s]结果:%s", itemId, roleName, result.data);
|
||||
res.json({ code: 0, msg: "发送成功!" });
|
||||
} catch (error) {
|
||||
|
||||
@@ -58,7 +58,6 @@ onMounted(() => {
|
||||
// 提交表单
|
||||
const submitForm = (formEl) => {
|
||||
formEl.validate().then(async () => {
|
||||
console.log(form.value);
|
||||
const params = form.value
|
||||
const res = await axios.post("/api/item/send", { roleName: params.playerName, itemId: params.item, itemNum: params.itemNum })
|
||||
const result = res?.data
|
||||
|
||||
Reference in New Issue
Block a user