CodeReview/frontend/docker-entrypoint.sh

16 lines
449 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
set -e
# 替换 API 地址占位符
# 默认为 /api/v1这样即使用户不传参也能配合默认的 nginx 代理工作
API_URL="${VITE_API_BASE_URL:-/api/v1}"
echo "Injecting API URL: $API_URL"
# 在所有 JS 文件中替换占位符
# 注意:这里路径必须是 nginx 实际存放文件的路径
find /usr/share/nginx/html -name '*.js' -exec sed -i "s|__API_BASE_URL__|${API_URL}|g" {} \;
# 执行原始命令
exec "$@"