补充方案
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
- `SUPA_USE_BEARER`(可选):是否附加 `Authorization: Bearer <SUPA_KEY>`,默认 `false`。
|
||||
- 在一些自托管 Supabase/Kong(key-auth)环境中,**只需要** `apikey`;如果误加 Bearer 且 key 不是 JWT,可能出现 `PGRST301`("None of the keys was able to decode the JWT")。
|
||||
- `WEBHOOK_SECRET`(可选):与第三方共享的 HMAC-SHA256 secret,用于校验 `X-Signature`(签名为 hex)
|
||||
- `WEBHOOK_REJECT_INVALID_SIGNATURE`(可选):若为 `true`,且配置了 `WEBHOOK_SECRET`,则验签失败会直接返回 HTTP 401(默认不拒绝,只记录)。
|
||||
- `WEBHOOK_PORT`(可选):接收器监听端口,默认 `7201`(推荐用这个,便于与 push-server 共享同一份 `server/config.json`)
|
||||
- `PORT`(可选):接收器监听端口(兼容旧用法;若共享 `server/config.json` 且其中 `PORT=7301`,会导致端口冲突)
|
||||
|
||||
@@ -85,6 +86,8 @@ curl -i -X POST http://localhost:7201/webhook/express/status \
|
||||
-d "$BODY"
|
||||
```
|
||||
|
||||
> 重要:签名计算必须使用**原始请求体文本**(raw body)。接收器也会使用 raw body 进行验签;不要用 JSON 对象 stringify 后的字符串替代。
|
||||
|
||||
健康检查:
|
||||
- `GET http://localhost:7201/health`(端口以 `PORT` 为准)
|
||||
|
||||
@@ -125,12 +128,15 @@ Stop-Process -Id <PID>
|
||||
验证写入(查看 Supabase):
|
||||
```bash
|
||||
# 示例:列最近 5 条原始回文
|
||||
curl -s -H "apikey: $SUPA_KEY" -H "Authorization: Bearer $SUPA_KEY" \
|
||||
curl -s -H "apikey: $SUPA_KEY" -H "Accept: application/json" \
|
||||
"$SUPA_URL/rest/v1/platform_express_event_raw?select=*&order=received_at.desc&limit=5" | jq .
|
||||
|
||||
# 查看最近轨迹事件
|
||||
curl -s -H "apikey: $SUPA_KEY" -H "Authorization: Bearer $SUPA_KEY" \
|
||||
curl -s -H "apikey: $SUPA_KEY" -H "Accept: application/json" \
|
||||
"$SUPA_URL/rest/v1/platform_express_tracking_events?select=*&order=created_at.desc&limit=5" | jq .
|
||||
|
||||
# 如果你的环境已确认 Bearer 可用(不会触发 PGRST301),也可以额外加上:
|
||||
# -H "Authorization: Bearer $SUPA_KEY"
|
||||
```
|
||||
|
||||
与仓库中 Mock 实现的关系:
|
||||
@@ -146,6 +152,6 @@ curl -s -H "apikey: $SUPA_KEY" -H "Authorization: Bearer $SUPA_KEY" \
|
||||
- 若需要我加重放防护或返回 4xx/5xx 更精确的逻辑,也可继续实现。
|
||||
|
||||
文件位置:
|
||||
- [Webhook 接收器](pages/mall/delivery/server/webhook-receiver.js)
|
||||
- [Webhook 接收器](pages/mall/delivery/webhook-server/webhook-receiver.js)
|
||||
|
||||
作者:自动生成(可手动调整)
|
||||
|
||||
Reference in New Issue
Block a user