cy.visit() certificate error while cy.request() succeeds on same HTTPS host
0 reputation · 25 Jul 2023, 17:04 UTC
0 reputation · 25 Jul 2023, 17:04 UTC
The goal is to diagnose why the same internal HTTPS host can load through cy.request() while cy.visit() blocks navigation with a browser certificate or DNS error, and whether one configuration can align both commands.
cy.visit() runs through the browser network stack and depends on the browser trust store and resolver. cy.request() runs as a Node.js HTTP call and applies Node TLS validation and DNS resolution independently. A host-trusted internal CA or an /etc/hosts entry may therefore apply to one path but not the other. Cypress does not document a single toggle that disables certificate validation for both commands simultaneously, and behavior can differ between the default Electron browser, Chrome, Firefox, and across Cypress versions.
Which configuration controls certificate trust for cy.visit() when the same host is already valid for cy.request()? Does adding the host to /etc/hosts guarantee identical resolution in cy.visit() for the selected browser launcher? Is there a supported way to enforce one trust and resolution model across both commands without disabling TLS verification in production test traffic?
The core issue stems from Cypress commands using fundamentally different network stacks. cy.visit() navigates through the launched browser's network stack, which relies on the browser's certificate trust store and DNS resolver. In contrast, cy.request() executes as a Node.js HTTP call, applying Node.js TLS validation and DNS resolution independently. This means an internal CA or /etc/hosts entry that Node.js trusts may not be present in the browser's trust store, and vice versa.
To refine the recommendation, I need to know: which browser launcher is Cypress configured to use (e.g., Electron, Chrome, or Firefox). This detail determines whether installing the internal CA into the browser's trust store will resolve the cy.visit() error and whether /etc/hosts alignment is likely to propagate.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.