From 3faeba0589cd1350e46eedccad743e51d39fb49d Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Mon, 2 Nov 2026 14:52:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(deploy):=20=E8=A1=A5=E5=85=85=20CORS=20?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E6=9D=A5=E6=BA=90=E9=81=BF=E5=85=8D=E8=B7=A8?= =?UTF-8?q?=E5=9F=9F=E8=A2=AB=E6=8B=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit app-api 增加 frostgiant 域名(含 nginx 非标准 80 端口)与公网 IP 来源; admin-api 增加公网/局域网 IP 与 admin.frostgiant.vip。 Spring setAllowedOrigins 为精确字符串匹配,来源必须逐条列全。 --- docker-compose.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3657414..624c462 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -78,6 +78,9 @@ services: # 限流/缓存用 Redis;容器内 127.0.0.1 是容器自身,必须指向编排里的 redis REDIS_HOST: ${REDIS_HOST:-redis} REDIS_PORT: ${REDIS_PORT:-6379} + # CORS:公网入口 nginx 把 SSL 跑在 80 端口上(腾讯云安全组只放 80), + # 浏览器 fetch 带 Origin 时端口不匹配会被 Spring CORS 拒(必须精确字符串匹配)。 + CORS_ALLOWED_ORIGINS: "https://api.frostgiant.vip:80,https://api.frostgiant.vip,http://api.frostgiant.vip,https://39.162.50.99:8081,http://localhost:3005,http://127.0.0.1:3005" ports: - "8081:8081" volumes: @@ -108,7 +111,8 @@ services: SERVER_PORT: "8080" SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE: "2GB" SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE: "2GB" - CORS_ALLOWED_ORIGINS: "http://localhost:3005,http://127.0.0.1:3005,http://39.162.50.99:3005,http://192.168.31.250:3005" + # 浏览后台时 Origin 是实际访问地址,必须精确列全:本机、局域网、公网 IP、域名。 + CORS_ALLOWED_ORIGINS: "http://localhost:3005,http://127.0.0.1:3005,http://39.162.50.99:3005,http://192.168.31.250:3005,https://api.frostgiant.vip,https://admin.frostgiant.vip" DB_URL: ${DB_URL:-jdbc:postgresql://db:5432/${DB_NAME:-fruitshorts}} # 管理端仅内网,页面上直接播放/下载裸媒资地址(不签播放签名), # 因此这里不启用 /files/episode/** 的签名校验;公开的 app-api 仍保持开启。