Use fixed same-origin API proxy
Verify mini program and deploy preview / verify-deploy (push) Successful in 4m34s
Verify mini program and deploy preview / verify-deploy (push) Successful in 4m34s
This commit is contained in:
@@ -16,7 +16,6 @@ jobs:
|
||||
SOURCE_REPOSITORY: ${{ gitea.repository }}
|
||||
SOURCE_REVISION: ${{ gitea.sha }}
|
||||
DEPLOY_PORT: ${{ vars.DEPLOY_PORT || '3002' }}
|
||||
API_BASE_URL: ${{ vars.API_BASE_URL }}
|
||||
steps:
|
||||
- name: Fetch exact revision
|
||||
env: { SOURCE_TOKEN: "${{ secrets.GITEA_TOKEN || gitea.token }}" }
|
||||
@@ -43,7 +42,7 @@ jobs:
|
||||
set -eu
|
||||
docker network inspect pk-lab-public >/dev/null 2>&1 || docker network create pk-lab-public
|
||||
docker rm -f rice-pk-xhs-preview 2>/dev/null || true
|
||||
docker run -d --name rice-pk-xhs-preview --restart unless-stopped --network pk-lab-public --read-only --tmpfs /tmp --tmpfs /var/cache/nginx --tmpfs /var/run -e API_BASE_URL="$API_BASE_URL" -p "$DEPLOY_PORT:8080" "rice-pk-xhs:$SOURCE_REVISION"
|
||||
docker run -d --name rice-pk-xhs-preview --restart unless-stopped --network pk-lab-public --read-only --tmpfs /var/cache/nginx --tmpfs /var/run -p "$DEPLOY_PORT:8080" "rice-pk-xhs:$SOURCE_REVISION"
|
||||
for i in 1 2 3 4 5 6 7 8 9 10; do
|
||||
status="$(docker inspect --format '{{.State.Health.Status}}' rice-pk-xhs-preview)"
|
||||
[ "$status" = healthy ] && exit 0
|
||||
|
||||
+1
-1
@@ -3,4 +3,4 @@ COPY web /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 8080
|
||||
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=5 CMD wget -q -O- http://127.0.0.1:8080/health || exit 1
|
||||
CMD ["/bin/sh","-c","envsubst '$API_BASE_URL' < /usr/share/nginx/html/runtime-env.js > /tmp/runtime-env.js && exec nginx -g 'daemon off;'"]
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
只开放 `rice` 测试的原生小红书小程序。打开即进入饭类主题,可重复测试、查看自己的饭类历史、输入综合版生成的一次性绑定码,并生成三种风格的分享图。
|
||||
|
||||
将 `app.js` 的 `apiBase` 改成生产 HTTPS API,在小红书后台配置合法域名并绑定独立版 App ID。CI 默认把公网功能预览常驻部署到宿主机 `3002`,并加入 `pk-lab-public` Docker 网络;浏览器同源请求 `/api`,由 Nginx 转发到 `pk-lab-api:8000`。`DEPLOY_PORT` 可覆盖,只有跨域部署时才需设置可选的 `API_BASE_URL`。
|
||||
将 `app.js` 的 `apiBase` 改成生产 HTTPS API,在小红书后台配置合法域名并绑定独立版 App ID。CI 默认把公网功能预览常驻部署到宿主机 `3002`,并加入 `pk-lab-public` Docker 网络;浏览器固定同源请求 `/api`,由 Nginx 转发到 `pk-lab-api:8000`。`DEPLOY_PORT` 可覆盖。
|
||||
|
||||
@@ -3,11 +3,6 @@ server {
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
location = /runtime-env.js {
|
||||
alias /tmp/runtime-env.js;
|
||||
add_header Cache-Control "no-store";
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
resolver 127.0.0.11 valid=10s ipv6=off;
|
||||
set $api_upstream http://pk-lab-api:8000;
|
||||
|
||||
+1
-2
@@ -1,2 +1 @@
|
||||
window.PK_CONFIG={apiBase:'${API_BASE_URL}'};
|
||||
|
||||
window.PK_CONFIG={apiBase:''};
|
||||
|
||||
Reference in New Issue
Block a user