Skip to content
This repository has been archived by the owner on Apr 11, 2019. It is now read-only.

Commit

Permalink
added custom CORS header field, fixed #4
Browse files Browse the repository at this point in the history
  • Loading branch information
bcho committed Sep 30, 2013
1 parent c0a2cac commit 5940ef1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from functools import wraps

from flask import make_response
from flask import make_response, request
from flask import jsonify as _jsonify

from server.db import db
Expand All @@ -28,7 +28,9 @@ def allow_CORS(*args, **kwargs):
if isinstance(rv, str) or isinstance(rv, unicode):
rv = make_response(rv)

rv.headers.add('Access-Control-Allow-Origin', '*')
origin = request.headers.get('Origin', None)
if origin:
rv.headers.add('Access-Control-Allow-Origin', origin)
return rv, status, headers
return allow_CORS

Expand Down

0 comments on commit 5940ef1

Please sign in to comment.