Files
heicode/heicode/deploy/nginx/heicode-gateway.conf
T
xiaohei 84104da111 fix: 修复登录时 /v1/models 空列表 panic 导致 500
- heicode/controller/model.go: Anthropic ListModels case 对空模型列表
  做边界保护,避免 index out of range panic -> HTTP 500
- cc-haha/src/server/services/providerService.ts: 模型探活不再发送
  anthropic-version header,统一走 OpenAI 兼容路径返回 {data:[]}
- heicode/controller/heicode_oauth.go: OAuth 未登录重定向指向 /sign-in
- heicode/deploy/nginx/heicode-gateway.conf: 3000 端口 server block
  补充 /models -> /v1/models 兼容路由
2026-05-07 09:56:50 +00:00

167 lines
3.8 KiB
Plaintext

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# NewAPI is an independent service. Its process listens on container port 3000.
# The gateway joins the NewAPI Docker network and reaches the service by
# container DNS, so NewAPI does not need a public host port for relay traffic.
upstream newapi_relay {
server new-api:3000;
}
upstream manager_app {
server heicode:3000;
}
server {
listen 80;
server_name newapi.xinghanlab.com;
client_max_body_size 64m;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# Keep the same relay-compatible behavior while exposing Manager UI on :80.
location = /v1/models {
proxy_pass http://newapi_relay;
}
location ^~ /v1/models/ {
proxy_pass http://newapi_relay;
}
location ^~ /v1/chat/completions {
proxy_pass http://newapi_relay;
}
location ^~ /v1/messages {
proxy_pass http://newapi_relay;
}
location ^~ /v1/completions {
proxy_pass http://newapi_relay;
}
location ^~ /v1/responses {
proxy_pass http://newapi_relay;
}
location ^~ /v1/embeddings {
proxy_pass http://newapi_relay;
}
location ^~ /v1/rerank {
proxy_pass http://newapi_relay;
}
location ^~ /v1/images/ {
proxy_pass http://newapi_relay;
}
location ^~ /v1/audio/ {
proxy_pass http://newapi_relay;
}
location ^~ /v1/moderations {
proxy_pass http://newapi_relay;
}
location ^~ /v1/realtime {
proxy_pass http://newapi_relay;
}
location ^~ /v1beta/ {
proxy_pass http://newapi_relay;
}
location / {
proxy_pass http://manager_app;
}
}
server {
listen 3000;
server_name code.xinghanlab.com newapi.xinghanlab.com _;
client_max_body_size 64m;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# Compatibility for older HeiCode desktop builds that probe /models
# instead of the OpenAI-compatible /v1/models endpoint.
location = /models {
proxy_pass http://newapi_relay/v1/models;
}
# Only relay-compatible API paths are sent to NewAPI. NewAPI admin/backend
# pages are intentionally not proxied through the public Manager gateway.
location = /v1/models {
proxy_pass http://newapi_relay;
}
location ^~ /v1/models/ {
proxy_pass http://newapi_relay;
}
location ^~ /v1/chat/completions {
proxy_pass http://newapi_relay;
}
location ^~ /v1/messages {
proxy_pass http://newapi_relay;
}
location ^~ /v1/completions {
proxy_pass http://newapi_relay;
}
location ^~ /v1/responses {
proxy_pass http://newapi_relay;
}
location ^~ /v1/embeddings {
proxy_pass http://newapi_relay;
}
location ^~ /v1/rerank {
proxy_pass http://newapi_relay;
}
location ^~ /v1/images/ {
proxy_pass http://newapi_relay;
}
location ^~ /v1/audio/ {
proxy_pass http://newapi_relay;
}
location ^~ /v1/moderations {
proxy_pass http://newapi_relay;
}
location ^~ /v1/realtime {
proxy_pass http://newapi_relay;
}
location ^~ /v1beta/ {
proxy_pass http://newapi_relay;
}
location / {
proxy_pass http://manager_app;
}
}