1
0
forked from erp-dev/erp

feat: sse && multi_merchant completed

This commit is contained in:
2025-11-11 10:56:20 +08:00
parent b2078dfa46
commit 2aafb93aad
43 changed files with 2445 additions and 244 deletions

View File

@@ -54,10 +54,14 @@ CORS_ALLOW_ALL_ORIGINS = DEBUG # 开发环境允许所有源,生产环境需
CORS_ALLOWED_ORIGINS = env.list('CORS_ALLOWED_ORIGINS', default=[
'http://localhost:3000',
'http://localhost:5173',
'http://localhost:5174',
'http://127.0.0.1:3000',
'http://127.0.0.1:5173',
'http://127.0.0.1:5174',
])
CORS_ALLOW_CREDENTIALS = True # 允许携带凭证(如 Cookie、认证头
# SSE 需要的特殊 CORS 配置
CORS_ALLOW_HEADERS = [
'accept',
'accept-encoding',
@@ -68,8 +72,22 @@ CORS_ALLOW_HEADERS = [
'user-agent',
'x-csrftoken',
'x-requested-with',
'cache-control', # SSE 需要
'x-accel-buffering', # SSE 需要
'last-event-id', # SSE 重连需要
# 注意:不要添加 'connection',这是 hop-by-hop 头部,会被代理过滤
]
# SSE 需要暴露的响应头
CORS_EXPOSE_HEADERS = [
'content-type',
'cache-control',
'x-accel-buffering',
]
# 预检请求缓存时间(秒)
CORS_PREFLIGHT_MAX_AGE = 86400 # 24小时
# Application definition
@@ -88,6 +106,8 @@ INSTALLED_APPS = [
'stock',
'api_v1',
'api_man',
'stateflow',
'sse',
]
MIDDLEWARE = [