C
C#3d ago
Ellopis

Configure Swagger UI through docker?

The curl Swagger is doing is:
curl -X 'GET' \
'http://[::]:8080/WeatherForecast' \
-H 'accept: text/plain'
curl -X 'GET' \
'http://[::]:8080/WeatherForecast' \
-H 'accept: text/plain'
Which is giving the fail: Failed to fetch. Possible Reasons: CORS Network Failure URL scheme must be "http" or "https" for CORS request. I'm using the default template + swaggerUI. I tried ScalarUI with the same results
11 Replies
Sehra
Sehra3d ago
ipv6 localhost would be [::1]
Ellopis
EllopisOP3d ago
I don't get it. Could you elaborate?
Sehra
Sehra3d ago
you said [::] above
Ellopis
EllopisOP3d ago
I did, that's what I get as base url info: Microsoft.Hosting.Lifetime[14] Now listening on: http://[::]:8080 0.0.0.0.0.0 I don't even know how to change it. I don't know why when I execute the queries they are failing. If I do them in postman with localhost:8080 they work.
Sehra
Sehra3d ago
:: here just means unspecified address
Ellopis
EllopisOP3d ago
Ou, how should I define it?
Sehra
Sehra3d ago
it's listening on all, but to connect you need to specify one, so you can use ::1 like 127.0.0.1 or localhost
Ellopis
EllopisOP3d ago
still, only working from postman, not Swagger (I'm running it from docker)
Sehra
Sehra3d ago
are you running the server outside docker, and curl inside docker?
Ellopis
EllopisOP3d ago
No, server inside docker, and the curl outside (like postman is doing I guess)
Sehra
Sehra3d ago
you can try starting the container with port mapping -p 8080:8080 then outside localhost:8080 would be forwarded to 8080 inside the container or might be able to do docker inspect and find the container's ip address and connect directly

Did you find this page helpful?