Skip to content

fix(market): 404 JSON for unknown API routes + OAuth ops runbook - #1874

Merged
bobleer merged 1 commit into
GCWing:mainfrom
bobleer:worktree-market-ops-sync
Jul 30, 2026
Merged

fix(market): 404 JSON for unknown API routes + OAuth ops runbook#1874
bobleer merged 1 commit into
GCWing:mainfrom
bobleer:worktree-market-ops-sync

Conversation

@bobleer

@bobleer bobleer commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Distills what we learned configuring GitHub OAuth on the production market server (2026-07-29/30) back into the repo.

Codesrc/crates/services/miniapp-market-service:

  • Unmatched /miniapp/api/v1/* paths used to fall through to the SPA and return 200 + index.html, which made API debugging genuinely confusing (a typoed auth path looks like a live endpoint). Because axum flattens nested routers, a nested .fallback() loses to the outer /miniapp/{*rest} catch-all — so this registers an explicit /{*rest} wildcard inside the API router instead. Unknown API routes now return the standard versioned 404 JSON envelope.
  • Regression test added (health_route_boots_with_an_empty_database now also asserts the 404 envelope).

Docsdeploy/miniapp-market/README.md:

  • New「GitHub OAuth 配置」subsection: OAuth Apps have no management API (manual web-only), client secrets display exactly once (reuse the app, rotate the secret), don't pass secrets as CLI args, plus read-only verification commands (healthgithubAuthConfigured:true, /auth/github/start → 307 to GitHub with matching client_id/redirect_uri).
  • Documented the SPA-fallback debugging pitfall for older deployed versions.
  • Gave「初次开放市场」its own subsection heading.

Testing

  • cargo test -p bitfun-miniapp-market-service — 19 passed
  • cargo check -p bitfun-miniapp-market-server — clean
  • cargo fmt --check — clean

…OAuth setup

Unmatched /miniapp/api/v1/* paths used to fall through to the SPA's
index.html (200 + HTML) because axum flattens nested routers and the
outer catch-all won. Register an explicit wildcard inside the API router
so unknown routes get the versioned error envelope.

Also add an operations subsection to the deploy runbook covering GitHub
OAuth App setup: no management API exists, secrets display only once,
reuse-and-rotate guidance, read-only verification via health and
/auth/github/start, and the SPA-fallback debugging pitfall.
@bobleer
bobleer marked this pull request as ready for review July 30, 2026 04:30
@bobleer
bobleer merged commit 0cfedc9 into GCWing:main Jul 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant