mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
added CORS for localhost
This commit is contained in:
parent
43f779a18b
commit
a3b01147e5
@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
The application is implemented in Flask and runs using Gunicorn.
|
The application is implemented in Flask and runs using Gunicorn.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
import copy
|
import copy
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
from flask_cors import CORS
|
||||||
import gunicorn.app.base
|
import gunicorn.app.base
|
||||||
|
|
||||||
from bigchaindb import utils
|
from bigchaindb import utils
|
||||||
@ -60,6 +61,30 @@ def create_app(*, debug=False, threads=4):
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
hostname = os.environ.get('DOCKER_MACHINE_IP', 'localhost')
|
||||||
|
|
||||||
|
if not hostname:
|
||||||
|
hostname = 'localhost'
|
||||||
|
|
||||||
|
origins = ('^(https?://)?(www\.)?({}|0|0.0.0.0|'
|
||||||
|
'localhost|127.0.0.1)(\.com)?:\d{{1,5}}$').format(hostname),
|
||||||
|
CORS(app,
|
||||||
|
origins=origins,
|
||||||
|
headers=(
|
||||||
|
'x-requested-with',
|
||||||
|
'content-type',
|
||||||
|
'accept',
|
||||||
|
'origin',
|
||||||
|
'authorization',
|
||||||
|
'x-csrftoken',
|
||||||
|
'withcredentials',
|
||||||
|
'cache-control',
|
||||||
|
'cookie',
|
||||||
|
'session-id',
|
||||||
|
),
|
||||||
|
supports_credentials=True,
|
||||||
|
)
|
||||||
|
|
||||||
app.debug = debug
|
app.debug = debug
|
||||||
|
|
||||||
app.config['bigchain_pool'] = utils.pool(Bigchain, size=threads)
|
app.config['bigchain_pool'] = utils.pool(Bigchain, size=threads)
|
||||||
|
1
setup.py
1
setup.py
@ -70,6 +70,7 @@ install_requires = [
|
|||||||
'python-rapidjson==0.0.8',
|
'python-rapidjson==0.0.8',
|
||||||
'logstats>=0.2.1',
|
'logstats>=0.2.1',
|
||||||
'flask>=0.10.1',
|
'flask>=0.10.1',
|
||||||
|
'flask-cors==2.1.2',
|
||||||
'flask-restful~=0.3.0',
|
'flask-restful~=0.3.0',
|
||||||
'requests~=2.9',
|
'requests~=2.9',
|
||||||
'gunicorn~=19.0',
|
'gunicorn~=19.0',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user