Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

When running Cypress.io tests in my dev environment, I'm getting this error when sending any requests to my local API (localhost). External APIs work and the code runs fine outside the context of Cypress tests.

cypress_runner.js:177238 GET http://localhost:4444/apicallname 400 (Bad Request)
XHR.send @ cypress_runner.js:177238
scheduleTask @ VM478 polyfills.js:2943
...
error @ VM479 vendor.js:32379
VM480 main.js:11997 Error:  {"_body":"WebSockets request was expected
","status":400,"ok":false,"statusText":"Bad Request","headers":{"connection":["keep-alive"],"content-encoding":["gzip"],"content-type":["text/html; charset=UTF-8"],"date":["Fri"," 01 Jan 2021 00:44:22 GMT"],"transfer-encoding":["chunked"],"vary":["Accept-Encoding"]},"type":2,"url":"http://localhost:4444/apicallname"}

I haven't had this issue before so I'm pretty confused why it's happening now. The same call with the same auth token works in Postman. The Node.js API I'm calling is not returning an error.

Update: If I use the machine's IP instead of "localhost" it works, but that's not ideal of course.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...