Skip to content

Commit 8c32a4b

Browse files
author
Jon Wayne Parrott
committed
Adding CORS
Change-Id: If898855d17d2cb33d0883c926c9f461b051e7d1c
1 parent b90dbe9 commit 8c32a4b

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

appengine/flexible/endpoints/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import logging
2424

2525
from flask import Flask, jsonify, request, send_from_directory
26+
from flask_cors import cross_origin
2627
from six.moves import http_client
2728
import yaml
2829

@@ -77,6 +78,7 @@ def auth_info_google_id_token():
7778

7879

7980
@app.route('/auth/info/firebase', methods=['GET'])
81+
@cross_origin(send_wildcard=True)
8082
def auth_info_firebase():
8183
"""Auth info with Firebase auth."""
8284
return auth_info()

appengine/flexible/endpoints/main_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,10 @@ def test_auth_info(client):
8282
assert r.status_code == 200
8383
data = json.loads(r.data.decode('utf-8'))
8484
assert data['id'] == '123'
85+
86+
87+
def test_cors(client):
88+
r = client.options(
89+
'/auth/info/firebase', headers={'Origin': 'example.com'})
90+
assert r.status_code == 200
91+
assert r.headers['Access-Control-Allow-Origin'] == '*'

appengine/flexible/endpoints/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Flask==0.11.1
2+
flask-cors==2.1.2
23
gunicorn==19.6.0
34
gcloud==0.17.0
45
six==1.10.0

0 commit comments

Comments
 (0)