Same-origin API: empty VITE_API_URL with nginx proxy to backend-1.

Frontends call /api/ on ark-library.com; nginx forwards internally to 100.93.205.19.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-23 17:42:59 +08:00
parent e6bc212c4e
commit 2c710e2e24
3 changed files with 119 additions and 1 deletions

View File

@@ -34,7 +34,7 @@ jobs:
- name: Build
run: npm run build
env:
VITE_API_URL: https://api.ark-library.com
VITE_API_URL: ""
VITE_DISABLE_ADMIN: "true"
- name: Setup SSH key
@@ -54,6 +54,22 @@ jobs:
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
dist/ \
ec2-user@${HOST}:/var/www/ark-library/
rsync -avz \
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
deploy/nginx-frontend-locations.inc \
ec2-user@${HOST}:/tmp/ark-library-frontend.inc
rsync -avz \
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
deploy/nginx-frontend-native.conf \
ec2-user@${HOST}:/tmp/ark-library-native.conf
ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no ec2-user@${HOST} bash -s <<'REMOTE'
set -euo pipefail
sudo mkdir -p /etc/nginx/snippets
sudo install -m 0644 /tmp/ark-library-frontend.inc /etc/nginx/snippets/ark-library-frontend.inc
sudo install -m 0644 /tmp/ark-library-native.conf /etc/nginx/conf.d/ark-library.conf
rm -f /tmp/ark-library-frontend.inc /tmp/ark-library-native.conf
sudo nginx -t && sudo systemctl reload nginx
REMOTE
echo ">>> $HOST 部署完成"
}
deploy_to "${{ secrets.FRONTEND_1_HOST }}" &