This commit is contained in:
beabigegg
2025-09-02 13:11:48 +08:00
parent a60d965317
commit b11a8272c4
76 changed files with 15321 additions and 200 deletions

View File

@@ -49,11 +49,13 @@ def create_app(config_name=None):
# 載入配置
config_name = config_name or os.getenv('FLASK_ENV', 'default')
app.config.from_object(config[config_name])
# 載入 Dify API 配置
# 載入 Dify API 配置
config[config_name].load_dify_config()
# 然後載入配置到 Flask app
app.config.from_object(config[config_name])
# 初始化必要目錄
config[config_name].init_directories()
@@ -92,7 +94,7 @@ def create_app(config_name=None):
@app.after_request
def after_request(response):
origin = request.headers.get('Origin')
allowed_origins = ['http://localhost:3000', 'http://127.0.0.1:3000']
allowed_origins = ['http://localhost:3000', 'http://127.0.0.1:3000', 'http://localhost:3001', 'http://127.0.0.1:3001']
if origin and origin in allowed_origins:
response.headers['Access-Control-Allow-Origin'] = origin
@@ -109,7 +111,7 @@ def create_app(config_name=None):
if request.method == 'OPTIONS':
response = make_response()
origin = request.headers.get('Origin')
allowed_origins = ['http://localhost:3000', 'http://127.0.0.1:3000']
allowed_origins = ['http://localhost:3000', 'http://127.0.0.1:3000', 'http://localhost:3001', 'http://127.0.0.1:3001']
if origin and origin in allowed_origins:
response.headers['Access-Control-Allow-Origin'] = origin