Files
stun-nav/EDGEONE.md
2026-07-12 17:13:38 +08:00

89 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# EdgeOne Pages 部署说明
这是 STUN Nav 的 EdgeOne Pages 专用部署说明。完整使用文档见 `README.md`。
## 文件结构
```text
public/ # 静态页面
edge-functions/api/[[default]].js # /api/* 接口
edgeone.json # EdgeOne 配置
```
## 部署步骤
1. 在 EdgeOne Pages / Makers 中创建项目。
2. 导入 GitHub 仓库。
3. 确认构建输出目录为:
```text
public
```
4. 创建 KV Namespace。
5. 给项目绑定 KV,变量名填写:
```text
STUN_NAV_KV
```
6. 添加环境变量:
```text
WEBHOOK_TOKEN=换成你自己的随机密钥
```
7. 部署项目。
## 访问地址
```text
https://你的域名/
https://你的域名/admin
```
## Lucky Webhook
GET 参数方式:
```text
https://你的域名/api/webhook/fnnas?token=你的随机密钥&name=FNNAS&group=NAS&url=http://{STUN_fnnas_ADDR}
```
POST JSON 方式:
```text
URL: https://你的域名/api/webhook/fnnas?token=你的随机密钥
Method: POST
Content-Type: application/json
Body:
{
"name": "FNNAS",
"group": "NAS",
"url": "http://{STUN_fnnas_ADDR}",
"note": "家里 NAS"
}
```
## 数据存储
EdgeOne 版本的数据保存在 KV 的这个 key 中:
```text
stun_nav_store
```
不会使用本地的 `data/links.json`。
## 故障排查
如果 `/api/services` 报 KV 错误,优先检查 KV 绑定变量名是不是:
```text
STUN_NAV_KV
```
如果 webhook 返回 `missing service url, addr, or host+port`,说明请求里没有传服务地址,需要增加 `url`、`addr`,或 `host + port`。
如果后台保存失败,检查输入的管理密钥是否和环境变量 `WEBHOOK_TOKEN` 一致。