Use http to talk to auth on prod, to save a round trip.

This commit is contained in:
Joshua Wise 2019-06-17 02:37:54 -04:00
parent c7de2b8fc2
commit 772c9b405b

View file

@ -11,6 +11,7 @@ app = Flask(__name__)
domain_root = os.environ['DOMAIN_ROOT'] domain_root = os.environ['DOMAIN_ROOT']
ibm_root = os.environ['IBM_API_ROOT'] ibm_root = os.environ['IBM_API_ROOT']
http_protocol = os.environ.get('HTTP_PROTOCOL', 'https')
# For some reason, the standard float converter rejects negative numbers # For some reason, the standard float converter rejects negative numbers
# (and also integers without a decimal point). # (and also integers without a decimal point).
@ -39,7 +40,7 @@ def heartbeat():
def geocode(latitude, longitude): def geocode(latitude, longitude):
if not request.args.get('access_token'): if not request.args.get('access_token'):
abort(401) abort(401)
user_req = requests.get(f"http://auth.{domain_root}/api/v1/me", user_req = requests.get(f"{http_protocol}://auth.{domain_root}/api/v1/me",
headers={'Authorization': f"Bearer {request.args['access_token']}"}) headers={'Authorization': f"Bearer {request.args['access_token']}"})
user_req.raise_for_status() user_req.raise_for_status()
if not user_req.json()['is_subscribed']: if not user_req.json()['is_subscribed']: