My API calls work correctly in Postman. But when I send requests from Swagger UI, it shows "no response from server" for all requests:
Response Body
no contentResponse Code
0Response Headers
{ "error": "no response from server" }
What can the problem be and how to fix it?
The browser console shows these errors:
Failed to load resource: net::ERR_CONNECTION_REFUSED
Uncaught TypeError: Cannot read property 'length' of undefined
at showStatus (index.js:24)
at showErrorStatus (index.js:24)
at error (index.js:607) at spec-converter.js:533
at Request.callback (index.js:24)
at Request.crossDomainError (index.js:24)
at XMLHttpRequest.xhr.onreadystatechange (index.js:24)
net::ERR_CONNECTION_REFUSED
sounds like you need to enable CORS on your localhost, so that it sends the Access-Control-Allow-Origin: *
header in responses. How you do this depends on the server you use. More info here:
https://enable-cors.org/server.html
https://github.com/swagger-api/swagger-ui/#cors-support
You may also need to allow OPTIONS pre-flight requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With