当我加载页面时,它会调用我的 API https://<apiurl>/products
.在 Cypress ,这个请求失败了:
GET https://<apiurl>/products net::ERR_EMPTY_RESPONSE
如果我复制 cURL 请求,响应会正常返回。我仔细检查了从 api 返回的 header ,没有 cors 问题。没有任何问题这是整个测试:
describe('Plans page', () => {
it('should load', () => {
cy.visit('http://localhost:8001/plans')
expect(1).to.eq(1)
})
})
"cypress": "6.8.0",
最佳答案
在我的案例中,问题是由公司代理引起的。我必须添加 proxy configuration . (我有完全相同的错误:net::ERR_EMPTY_RESPONSE)
Linux:
export http_proxy=http://...
export https_proxy=http://...
export NO_PROXY=...
cypress open
关于 Cypress 网::ERR_EMPTY_RESPONSE 6.8.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66961734/