Repository navigation
eNotify 初始化接口只保留 POST,移除 GET /api/setup/:secret - #111
Merged
todosdev[bot] merged 1 commit intoOct 17, 2026
Merged
Conversation
- Replace GET /api/setup/:secret with a 405 handler (Allow: POST) so the setup secret no longer leaks into browser history, access logs, Referer, or link previews. - Keep POST /api/setup (X-Setup-Secret header) unchanged, including safeEqual comparison and runMigrations on repeat calls. - Update README.md / README.en.md to document the curl POST flow and recommend rotating SETUP_SECRET for deployments that used the old URL. Checkpoint: 6JK1LKzo0sO2d4gQpz46f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/setup/:secret初始化入口:setup secret 不再出现在 URL 中,避免泄露到浏览器历史、访问日志、Referer 和链接预览。POST /api/setup(secret 走X-Setup-Secret请求头,safeEqual比较),行为保持不变。Changes
worker/src/routes/setup.tssetupRoutes.get("/:secret", ...)替换为setupRoutes.get("*", ...):任何GET /api/setup/*一律返回405,响应头带Allow: POST,并提示改用POST /api/setup+X-Setup-Secret请求头,不再执行任何初始化/迁移。POST /api/setup(读X-Setup-Secret头)逻辑原样保留。README.md/README.en.mdcurl -X POST … -H "X-Setup-Secret: <SETUP_SECRET>"示例。GET /api/setup/<SETUP_SECRET>已废弃(返回 405),并建议访问过旧 URL 的部署轮换SETUP_SECRET。Testing
wrangler dev --local实测:GET /api/setup/<正确secret>→405 Method Not Allowed,带Allow: POST,D1 无任何用户表变化(仅剩 miniflare 内部_cf_METADATA)。POST /api/setup+ 正确 secret →200 {"success":true};再次调用 →200 {"success":true,"alreadyInitialized":true}(跑迁移)。POST /api/setup+ 错误 secret / 缺失 secret →403 {"error":"Invalid setup secret"}。pnpm lint、pnpm format:check、pnpm typecheck、pnpm build全部通过。