修复错误

This commit is contained in:
yml
2026-04-09 18:11:02 +08:00
parent 4c395103a9
commit a95247cd01
6 changed files with 27 additions and 11 deletions
+6 -5
View File
@@ -1,11 +1,12 @@
APP_DOMAIN=926d-193-176-84-20.ngrok-free.app
APP_BASE_URL=https://926d-193-176-84-20.ngrok-free.app
CADDY_SITE_ADDR=http://926d-193-176-84-20.ngrok-free.app
# 当前模板用于 mac 本机 Docker 测试。
# 开发版 Caddy 会接受任意 Host,所以 ngrok / cloudflared 地址变化时通常只需要改 APP_BASE_URL。
APP_BASE_URL=http://localhost
# 当前模板用于 mac 本机 Docker 测试,并通过 ngrok 转发到 localhost:80
# 如需给外部用户发送领取链接,把 APP_BASE_URL 改成当前公网地址
# 只有当领取页入口与整站入口不同,才需要单独覆盖 CLAIM_BASE_URL。
TZ=Asia/Shanghai
BACKEND_PORT=3000
CLAIM_BASE_URL=https://926d-193-176-84-20.ngrok-free.app/#/claim
CLAIM_BASE_URL=http://localhost/#/claim
DATABASE_URL=postgres://postgres:postgres@postgres:5432/order_site
DATABASE_SSL=false
DATABASE_MAX_CONNECTIONS=10
+12
View File
@@ -51,6 +51,13 @@ cp .env.development.example .env
docker compose -f docker-compose.dev.yml up -d --build
```
开发环境现在不再把 Caddy 绑定到固定域名。
这意味着:
- 本地直接访问 `http://localhost` 可用
- 用 ngrok / cloudflared 转发到 `http://localhost:80` 时,不需要因为随机子域名变化而改 Caddy 配置
- 如果要生成发给用户的公网领取链接,只需要更新 `.env` 里的 `APP_BASE_URL`
开发版 Compose 现在是热更新模式:
- `postgres` 容器提供 PostgreSQL
@@ -96,6 +103,11 @@ docker compose build \
- 后端健康检查:`https://你的域名/health`
- 后端接口前缀:`https://你的域名/api/v1/...`
开发环境下的链接生成规则:
- 优先使用 `CLAIM_BASE_URL`
- 如果未设置 `CLAIM_BASE_URL`,后端会自动根据 `APP_BASE_URL` 推导为 `APP_BASE_URL/#/claim`
开发时如果只改业务代码,直接保留 `docker compose -f docker-compose.dev.yml up -d` 即可:
- 改后端 `src/`:容器内自动热重启
+5
View File
@@ -149,6 +149,11 @@ function applyEnvOverrides(baseConfig) {
const claimBaseUrl = String(process.env.CLAIM_BASE_URL || '').trim()
if (claimBaseUrl) {
nextConfig.orders.claimBaseUrl = claimBaseUrl
} else {
const appBaseUrl = String(process.env.APP_BASE_URL || '').trim()
if (appBaseUrl) {
nextConfig.orders.claimBaseUrl = `${appBaseUrl.replace(/\/+$/, '')}/#/claim`
}
}
const tokenTtlHours = parseInteger(process.env.CLAIM_TOKEN_TTL_HOURS)
@@ -12,7 +12,7 @@ import { nowIso } from '../../utils/time.js'
export async function processAgisoTradeWebhook(requestLike) {
const parsed = parseAgisoTradeRequest(requestLike)
const webhookEvent = createWebhookEvent(buildWebhookEventInput(requestLike, parsed))
const webhookEvent = await createWebhookEvent(buildWebhookEventInput(requestLike, parsed))
logWebhook('[webhook-service/agiso]', 'Webhook 已解析并写入 webhook_events', {
requestId: requestLike.requestId || '',
@@ -94,7 +94,7 @@ async function executeAgisoTradeWebhook(parsed, webhookEventId, { requestId = ''
webhookEventId,
})
const result = await upsertOrderFromWebhook(enriched.parsed)
updateWebhookEvent(webhookEventId, {
await updateWebhookEvent(webhookEventId, {
processed: true,
process_error: '',
related_order_id: result.order.id,
@@ -140,7 +140,7 @@ async function executeAgisoTradeWebhook(parsed, webhookEventId, { requestId = ''
})),
}
} catch (error) {
updateWebhookEvent(webhookEventId, {
await updateWebhookEvent(webhookEventId, {
processed: false,
process_error: error instanceof Error ? error.message : String(error || ''),
related_order_id: null,
+1 -1
View File
@@ -1,4 +1,4 @@
{$CADDY_SITE_ADDR:http://localhost}, http://localhost, http://127.0.0.1 {
:80 {
route {
handle /api/* {
reverse_proxy backend:3000
-2
View File
@@ -89,8 +89,6 @@ services:
- "443:443"
environment:
TZ: ${TZ:-Asia/Shanghai}
APP_DOMAIN: ${APP_DOMAIN:-localhost}
CADDY_SITE_ADDR: ${CADDY_SITE_ADDR:-http://localhost}
volumes:
- ./deploy/caddy/Caddyfile.dev:/etc/caddy/Caddyfile:ro