I'm sending multiple API requests and everything works fine, until I try to navigate to the page that was generated during API testing. When I navigate to the page using cy.visit() function I get unauthorized and all subsequent requests are being sent without authorization token, even though I added authorization header to the cy.visit() function.
Any help would be appreciated
var accessToken
before(function () {
cy.request({
method: 'POST',
url: 'https://someurl.com/connect/token',
form: true,
body: {
grant_type: 'password',
username: 'admin',
password: 'pass',
client_id: 'client_id',
client_secret: 'secret'
}
}).then((response) => {
accessToken = response.body.access_token
})
})
//api requests
it('Navigates to order page', () => {
cy.visit(`https://someurl.com/orders/${orderId}`, { auth: { bearer: accessToken.replace('Bearer ', '') } })
})

