Chrome扩展程序获取功能不会发送Cookie

问题描述 投票:1回答:1

我有一个chrome扩展,使用fetch函数对运行laravel的服务器执行ajax调用。

清单权限

"permissions": [
  "webRequest",
  "webRequestBlocking",
  "webNavigation",
  "activeTab",
  "tabs",
  "cookies",
  "<all_urls>"
],

取电话

fetch(this.url, {
  credentials: 'include',
  method: 'post',
  headers: {
    "Content-type": "application/x-www-form-urlencoded"
  },
  body: encodeDataToURL(telemetry)
})
.then(function (data) {
  console.log('Request succeeded with JSON response', data);
})
.catch(function (error) {
  console.log('Request failed', error);
});

曲奇饼

siusession=eyJpdiI6InlRS2wyb1BCZnJSSGtUaXVRelV4M3c9PSIsInZhbHVlIjoiRThteUk4MmVxeXV6a1N5ZUxTaFpxcUtSazJQRE1ZUUNQUWlBREVTdHRQM2pjNEVJUVUxd3gwM1JZMDNjOXR2TyIsIm1hYyI6ImUwMGQyNmAAhwQ3YWQ4YzRhOWVhYTk2ZjI2NDgwNTljNDE2YWU5NTdlZWM1MThiZWJjYzI3NmZjZWRhOGRlMzIifQ%3D%3D; expires=Tue, 25-Sep-2018 04:28:56 GMT; Max-Age=28800; path=/; secure; httponly; samesite=lax

我在我的浏览器上打开了一个关于该域的会话,这使我得到了Session IDXSRF-TOKEN的cookie。

问题是,它不会通过调用发送cookie。在Firefox上,相同的代码和清单确实发送浏览器cookie与调用。

有什么不对? chrome是否需要某种不同的权限或其他方式来进行包括cookie的调用?

laravel google-chrome cookies google-chrome-extension
1个回答
1
投票

假设提取调用是从后台脚本进行的,您需要查询cookie并将其插入http标头中。

© www.soinside.com 2019 - 2024. All rights reserved.