Compare commits

..
3 Commits
Author SHA1 Message Date
xrain 92f110c5e1 如果仓库有nginx.conf就用仓库的 2026-10-06 04:24:46 +08:00
xrain 4e2c837eee fix ci 2026-10-04 23:13:05 +08:00
xrain c18893e6f3 nginx增加了允许跨域 2026-05-04 18:00:58 +08:00
2 changed files with 25 additions and 4 deletions
+13 -4
View File
@@ -8,16 +8,25 @@ runs:
with:
entrypoint: "/bin/bash"
args: |
-c "export https_proxy=http://100.100.13.14:8118 && \
export http_proxy=http://100.100.13.14:8118 && \
npm pkg set version=${{ github.ref_name }} && \
-c "npm pkg set version=${{ github.ref_name }} && \
npm ci && \
npm run build-only"
# 项目根目录有 nginx.conf 就用项目自己的(例如要开 COOP/COEP 之类的自定义配置),
# 没有才用本 action 自带的通用配置
- uses: docker://ubuntu:latest
with:
entrypoint: "/bin/bash"
args: |
-c 'cp "${{ github.action_path }}/nginx.conf" ./ && cp "${{ github.action_path }}/vue.Dockerfile" ./Dockerfile'
-c '
set -e
if [ -f ./nginx.conf ]; then
echo "nginx.conf:用项目根目录的"
else
cp "${{ github.action_path }}/nginx.conf" ./nginx.conf
echo "nginx.conf:用 action 自带的"
fi
cp "${{ github.action_path }}/vue.Dockerfile" ./Dockerfile
'
- uses: actions/docker-build-push@main
+12
View File
@@ -3,6 +3,18 @@ server {
root /usr/share/nginx/html;
index index.html;
# 👇 跨域配置开始
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE' always;
add_header Access-Control-Allow-Headers '*, Origin, X-Requested-With, Content-Type, Accept, Authorization, X-Token' always;
add_header Access-Control-Allow-Credentials 'true' always;
# 处理预检 OPTIONS 请求
if ($request_method = 'OPTIONS') {
return 204;
}
# 👆 跨域配置结束
location / {
try_files $uri $uri/ /index.html;
}