Open jmaldon1 opened 4 years ago
SOLUTION:
I had to add PGRST_OPENAPI_SERVER_PROXY_URI
:
environment:
PGRST_DB_URI: postgres://${PGUSER}:${PGPASS}@${HOSTNAME}:5432/postgres?sslmode=require
PGRST_DB_SCHEMA: api
PGRST_DB_ANON_ROLE: app_user
PGRST_OPENAPI_SERVER_PROXY_URI: "http://127.0.0.1:3000/"
I had the wrong syntax earlier, and I guess for some reason on mac it can access http://0.0.0.0
, but on windows it can't? Not really sure whats up with that.
I guess we can close.
@jmaldon1 Glad you could solve it.
Seeing the windows problem, perhaps we should default to 127.0.0.1
instead of 0.0.0.0
for the OpenAPI host?
We add 0.0.0.0
in these lines:
@steve-chavez That seems like a good solution assuming you were able to recreate the issue and its a common windows thing and not just my machine being dumb haha.
I think we should just default to not setting schemes
and host
in the OpenAPI schema at all, if not specified via configuration. This is because we can never guess it correctly when behind a proxy anyway, right?
https://swagger.io/docs/specification/2-0/api-host-and-base-path/
If schemes are not specified, the scheme used to serve the API specification will be used for API calls. [...] If host is not specified, it is assumed to be the same host where the API documentation is being served. [...] Omitting host and scheme host and schemes can be omitted for a more dynamic association. In this case, the host and scheme used to serve the API documentation will be used for API calls.
This should then work for any OS?
Environment
Description of issue
docker-compose.yaml
I am getting various failed to fetch errors when trying to use the swagger UI.
When running on
Chrome
browser: I am getting aTypeError: Failed to fetch
error when using the swagger UI. When looking at the browser dev console i getnet::ERR_ADDRESS_INVALID
.When running on
Firefox
browser: I am getting aTypeError: NetworkError when attempting to fetch resource.
error when using the swagger UI. When looking at the browser dev console I getCross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://0.0.0.0:3000/outfits. (Reason: CORS request did not succeed).
.Everything works fine when hitting the postgrest server from any other means besides browser such as Postman or Curl.
The strange part is that I have a macbook that I ran this same
docker-compose up
on and the swagger UI works over there (same versions of everything).UPDATE: When i put the address
http://0.0.0.0:3000
in my browser I getThis site can’t be reached
. When i put the addresshttp://localhost:3000
in my browser it works fine.