Javascript 给出错误:“DOMException:无法从 'Document' 读取 'cookie' 属性:拒绝访问此文档。”
我将所有 cookie 设置为使用 HttpOnly = false ,但它似乎没有帮助。如果我在没有 puppeteer 的情况下调用该页面,该页面将完美运行。
我目前从初始化 puppeteer 的请求中复制所有会话变量:
var cookies = new List<CookieParam>();
foreach (var key in request.Cookies.Keys)
{
var cookie = request.Cookies.Get(key.ToString());
cookies.Add(new CookieParam {
Name = cookie.Name,
Value = cookie.Value,
HttpOnly = false,
Domain = cookie.Domain,
Url = baseUrl,
Path = cookie.Path,
Secure = cookie.Secure
});
}
await page.SetCookieAsync(cookies.ToArray());