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.
|
||||
"""
|
||||
|
||||
import os
|
||||
import copy
|
||||
import multiprocessing
|
||||
|
||||
from flask import Flask
|
||||
from flask_cors import CORS
|
||||
import gunicorn.app.base
|
||||
|
||||
from bigchaindb import utils
|
||||
@ -60,6 +61,30 @@ def create_app(*, debug=False, threads=4):
|
||||
|
||||
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.config['bigchain_pool'] = utils.pool(Bigchain, size=threads)
|
||||
|
Loading…
x
Reference in New Issue
Block a user