0

The tests pass in headed Chrome. They fail in headless Chrome and Electron (headed Electron also fails). I'm setting the web security flag to false for each browser in the Cypress/Plugins file. As best I can tell from the logs is that the Options pre flight isn't even being made. The headless browser just return 403 CORS error. The backend server is not even being hit. I'm left wondering if there's another mechanism at work blocking all headless CORS requests.

nullsteph
  • 587
  • 12
  • 22

1 Answers1

1

Found a solution for headless Chrome in this SO post

Still no idea about headless Electron.

For other Cypress users: 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;
    }
});
nullsteph
  • 587
  • 12
  • 22