Skip to content

Commit

Permalink
add env host ip
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrodriguezc committed Jul 17, 2024
1 parent 78e8424 commit 782ba0b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions bin/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# Backend-Frontend: Access-Control-Allow-Origin
PORT_CORE = int(os.environ.get('PORT_CORE', 8080))
PORT_APP = int(os.environ.get('PORT_APP', 3000))
HOST_IP = os.environ.get('HOST_IP')

# create HOST list for the cross-reference
CORS_HOSTS = [f"http://localhost:{PORT_APP}"]
Expand All @@ -41,8 +42,8 @@ def is_valid_ip(ip_str):
return True
except ValueError:
return False
if os.environ.get('HOST_IP') is not None and is_valid_ip(os.environ.get('HOST_IP')):
CORS_HOSTS.append(f"http://{os.environ.get('HOST_IP')}:{PORT_APP}")
if HOST_IP is not None and is_valid_ip(HOST_IP):
CORS_HOSTS.append(f"http://{HOST_IP}:{PORT_APP}")



Expand Down
2 changes: 1 addition & 1 deletion bin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ async def post(self):
raise KeyError('Backend must be either \'json\' or \'mongo\'')

# start the event loop
print('The API is listening on http://0.0.0.0:%d' % (tornado.options.options.port), flush=True)
print('The API is listening on http://%s:%d' % (env.HOST_IP, tornado.options.options.port), flush=True)
tornado.ioloop.IOLoop.current().start()

except KeyboardInterrupt:
Expand Down

0 comments on commit 782ba0b

Please sign in to comment.