Merge pull request #131 from andersonDadario/bugfix/Issue-130-Restrict-CORS-to-localhost

fix #130 - restrict cors to localhost
This commit is contained in:
Alex Yatskov 2019-12-25 19:00:57 -08:00 committed by GitHub
commit 06c40ed85d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,6 +39,7 @@ from string import ascii_letters
API_VERSION = 6 API_VERSION = 6
API_LOG_PATH = None API_LOG_PATH = None
NET_CORS_ORIGIN = os.getenv('ANKICONNECT_CORS_ORIGIN', 'http://localhost')
NET_ADDRESS = os.getenv('ANKICONNECT_BIND_ADDRESS', '127.0.0.1') NET_ADDRESS = os.getenv('ANKICONNECT_BIND_ADDRESS', '127.0.0.1')
NET_BACKLOG = 5 NET_BACKLOG = 5
NET_PORT = 8765 NET_PORT = 8765
@ -199,7 +200,7 @@ class WebServer:
self.headers = [ self.headers = [
['HTTP/1.1 200 OK', None], ['HTTP/1.1 200 OK', None],
['Content-Type', 'text/json'], ['Content-Type', 'text/json'],
['Access-Control-Allow-Origin', '*'] ['Access-Control-Allow-Origin', NET_CORS_ORIGIN]
] ]
self.headersOpt = {} self.headersOpt = {}