fix(deploy): 跨域来源未配置时默认放行
This commit is contained in:
@@ -250,7 +250,7 @@ setup_env_files() {
|
||||
SECURITY_ENV_MODE="new"
|
||||
fi
|
||||
|
||||
local web_port server_port ws_port asg_port public_scheme socket_scheme public_host security_origins
|
||||
local web_port server_port ws_port asg_port public_scheme socket_scheme public_host
|
||||
web_port="$(awk -F= '$1 == "WEB_PORT" { print $2; exit }' .env | tr -d '[:space:]')"
|
||||
web_port="${web_port:-3010}"
|
||||
server_port="$(awk -F= '$1 == "SERVER_HTTP_PORT" { print $2; exit }' .env | tr -d '[:space:]')"
|
||||
@@ -264,10 +264,8 @@ setup_env_files() {
|
||||
socket_scheme="ws"
|
||||
if [ "$DEPLOY_MODE" = "ip" ]; then
|
||||
public_host="$DEPLOY_IP"
|
||||
security_origins="http://${DEPLOY_IP}"
|
||||
else
|
||||
public_host="$DEPLOY_DOMAIN"
|
||||
security_origins="https://${DEPLOY_DOMAIN},http://${DEPLOY_DOMAIN}"
|
||||
if [ "$DEPLOY_HTTPS" = true ]; then
|
||||
public_scheme="https"
|
||||
socket_scheme="wss"
|
||||
@@ -278,7 +276,6 @@ setup_env_files() {
|
||||
upsert_env_value .env NUXT_PUBLIC_BASE_APIURL "/api"
|
||||
upsert_env_value .env NUXT_PUBLIC_BASE_SOCKETURL "${socket_scheme}://${public_host}/socket.io"
|
||||
upsert_env_value .env NUXT_PUBLIC_SG_APIURL "/asg-api"
|
||||
upsert_env_value .env CONFIG_SECURITY_ORIGIN "$security_origins"
|
||||
upsert_env_value .env EASYAI_PROXY_BIND_IP "127.0.0.1"
|
||||
upsert_env_value .env EASYAI_INFRA_BIND_IP "127.0.0.1"
|
||||
upsert_env_value .env GATEWAY_INBOUND_TCP_LISTEN_HOST "172.21.0.6"
|
||||
@@ -660,6 +657,7 @@ main() {
|
||||
else
|
||||
init_public_api_base_url .env configure "$PUBLIC_API_BASE_URL_CANDIDATE"
|
||||
fi
|
||||
# CONFIG_SECURITY_ORIGIN 为可选项:留空时后端默认允许所有来源,显式配置时才校验。
|
||||
# shellcheck source=scripts/init-security-origin.sh
|
||||
. ./scripts/init-security-origin.sh
|
||||
init_security_origin .env
|
||||
|
||||
Reference in New Issue
Block a user