refactor: extract cors configs into dify config and cleanup the config class (#5507)
Co-authored-by: takatost <takatost@gmail.com>pull/5492/head
parent
ec1d3ddee2
commit
2a0f03a511
@ -1,42 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
import dotenv
|
|
||||||
|
|
||||||
DEFAULTS = {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def get_env(key):
|
|
||||||
return os.environ.get(key, DEFAULTS.get(key))
|
|
||||||
|
|
||||||
|
|
||||||
def get_bool_env(key):
|
|
||||||
value = get_env(key)
|
|
||||||
return value.lower() == 'true' if value is not None else False
|
|
||||||
|
|
||||||
|
|
||||||
def get_cors_allow_origins(env, default):
|
|
||||||
cors_allow_origins = []
|
|
||||||
if get_env(env):
|
|
||||||
for origin in get_env(env).split(','):
|
|
||||||
cors_allow_origins.append(origin)
|
|
||||||
else:
|
|
||||||
cors_allow_origins = [default]
|
|
||||||
|
|
||||||
return cors_allow_origins
|
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
|
||||||
"""Application configuration class."""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
dotenv.load_dotenv()
|
|
||||||
|
|
||||||
self.TESTING = False
|
|
||||||
self.APPLICATION_NAME = "langgenius/dify"
|
|
||||||
|
|
||||||
# cors settings
|
|
||||||
self.CONSOLE_CORS_ALLOW_ORIGINS = get_cors_allow_origins(
|
|
||||||
'CONSOLE_CORS_ALLOW_ORIGINS', get_env('CONSOLE_WEB_URL'))
|
|
||||||
self.WEB_API_CORS_ALLOW_ORIGINS = get_cors_allow_origins(
|
|
||||||
'WEB_API_CORS_ALLOW_ORIGINS', '*')
|
|
||||||
@ -1,4 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
pytest api/tests/integration_tests/vdb/
|
pytest api/tests/integration_tests/vdb/chroma \
|
||||||
|
api/tests/integration_tests/vdb/milvus \
|
||||||
|
api/tests/integration_tests/vdb/pgvecto_rs \
|
||||||
|
api/tests/integration_tests/vdb/pgvector \
|
||||||
|
api/tests/integration_tests/vdb/qdrant \
|
||||||
|
api/tests/integration_tests/vdb/weaviate \
|
||||||
|
api/tests/integration_tests/vdb/test_vector_store.py
|
||||||
Loading…
Reference in New Issue