测试以Chrome为首通过。他们在无头的Chrome和Electron上失败了(headed也失败了)。我在Cypress/Plugins文件中为每个浏览器将web安全标志设置为false。从日志中我可以看出,飞行前的选项甚至都没有做出。无头浏览器只返回403 CORS错误。后端服务器甚至没有受到攻击。我想知道是否有另一种机制在阻止所有的无头CORS请求。
发布于 2020-04-10 23:27:14
在这个SO post中找到了无头Chrome的解决方案
还是对无头电子一无所知。
对于其他Cypress用户:Cypress/plugins/index.js
module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, launchOptions) => {
console.log('..browser ', launchOptions);
if (browser.name === 'chrome') {
launchOptions.args.push('--disable-site-isolation-trials');
launchOptions.args.push('--reduce-security-for-testing');
launchOptions.args.push('--out-of-blink-cors');
return launchOptions;
}
if (browser.name === 'electron') {
launchOptions.preferences.webPreferences.webSecurity = false;
return launchOptions;
}
});https://stackoverflow.com/questions/61133507
复制相似问题