OpenAgricultureFoundation / openag_brain_docker_rpi

Docker-compose configuration for openag_brain
GNU General Public License v3.0
19 stars 12 forks source link

fixed 5000 port forwarding #12

Closed yaromins closed 8 years ago

yaromins commented 8 years ago

5000 port forwarding was not configured from docker container to local machine. Due to this OpenAg UI was not able to communicate to any openag_brain api

LeonChambers commented 8 years ago

CouchDB is set up to proxy the Flask API under the URL /_openag. Having the UI use this proxy instead of hitting the Flask API directly could also fix this. Using CouchDB as a proxy for the API might also allow us to enforce a security model on the API through CouchDB so that credentials are set once in the DB config and apply to all HTTP requests. Haven't looked into CouchDB documentation enough to know if the auth config actually affects the HTTP proxy though, but I think it should. @gordonbrander thoughts?

yaromins commented 8 years ago

@LeonChambers I see, thank you for clarification. @gordonbrander than it is bug in Openag UI config file, since it assumes direct access "api": "{{root_url}}:5000/api/0.0.1".

Once I changed it to "{{root_url}}:5984/_openag/api/0.0.1" I've got another issue, now with a CORS setup:

Fetch API cannot load http://192.168.88.225:5984/_openag/api/0.0.1/service/environment_1/start_recipe. The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost, http://localhost', but only one is allowed. Origin 'http://localhost' is therefore not allowed access. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Yet to figure out how to solve this one.

yaromins commented 8 years ago

My guess that the latest issue is due to CORS enabled in two places - first in openag_brain and then second time in CouchDb.

yaromins commented 8 years ago

Yes, indeed, I removed CORS(app) in api.py and it helped.

gordonbrander commented 8 years ago

I've updated the UI. We can also remove CORS from the Flask API, so this PR can be closed.