https://cypress.io logo
cypress exists after one Get request
# i-need-help
f
Hi Group, I am one month new to cypress. My first cypress E2E scripts succeeded on login step which using an external url to authorize login user, but failed on clicking step on our application dashboard which is supposed to open a new page. The cypress log in VS code terminal shows one of the requests after clicking failed (#401) GET /api/auth-service/v1/user/current/user 401 83.391 ms - - and followed by GET /logout 200 98.970 ms - - I verified the application session storage before this clicking step inside cypress chrome, which contains all the information in the real chrome browser at the same step, including access token. I am wondering how to debug further to find what caused this Get request failed. Thanks, Cheng
I found a way to delay the logout request and caught the details of the auth request headers. cy.intercept('/logout', (req) => { req.on('response', (res) => { // Wait for delay in milliseconds before sending the response to the client. res.setDelay(100000) }) }) It seems the cookies were not included in the request headers by cypress although the cookies are in the session storage. Who can help me understand the cypress behavior in my case?
I noticed cypress changed the auth request from https to http, and the port number from 443 to a random port number 49190. Please refer the attached the screen shots. The first one was caught in a real browser, and the second one was caught inside cypress chrome.

https://cdn.discordapp.com/attachments/1107796241728942150/1108155650581725194/Screenshot_2023-05-16_at_3.01.37_PM.png

https://cdn.discordapp.com/attachments/1107796241728942150/1108155650820812891/Screenshot_2023-05-16_at_3.01.18_PM.png

I set baseURL in cypress configuration file already. I put our app url instead of "https://*****" in our cypress config file. const { defineConfig } = require("cypress"); module.exports = defineConfig({ e2e: { baseURL: 'https://******', setupNodeEvents(on, config) { on('task',{ log(message){ console.log(message) return null }, }) }, chromeWebSecurity: false, testIsolation: false, viewportWidth: 1400, viewportHeight: 1200, }, });