fix(topup): use theme-aware return URLs for epay and stripe - #4620
Conversation
The default frontend (v1) reorganized routes to drop the `/console/` prefix, so paths like `/console/log` and `/console/topup` no longer exist there. Payment return/cancel URLs were still hardcoded to the classic paths, causing 404s when users return to new-api after completing payment on the v1 UI. This selects the appropriate path at request time based on `common.GetTheme()`: - epay return_url: /usage-logs (default) | /console/log (classic) - stripe success URL: /usage-logs (default) | /console/log (classic) - stripe cancel URL: /wallet (default) | /console/topup (classic) The classic paths remain the fallback, so existing classic deployments are unaffected. Theme switching takes effect immediately since GetTheme() reads an atomic value updated when the admin flips the frontend setting.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR adds theme-aware logic to payment return URLs. ChangesTheme-Based Payment Redirect URLs
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Calcium-Ion
left a comment
There was a problem hiding this comment.
审了 diff,改动本身 LGTM:
controller/topup.go和controller/topup_stripe.go根据common.GetTheme()判断返回路径,default 主题用/usage-logs和/wallet,classic 用/console/log和/console/topup。- 逻辑简单清晰,无后端兼容问题。
但有两个问题:
- PR 目前有 merge conflicts,需要 rebase 到最新 main。
- Issue #4765 还提到了
topup_waffo*和subscription_payment_*控制器也有同样的硬编码路径问题,这个 PR 只覆盖了 epay 和 stripe。是否需要追一个补丁 PR 覆盖其余支付控制器?
请 rebase 解决冲突后我再 approve + merge。
|
感谢 @Calcium-Ion 的 review! 注意到 upstream 已经在 #4802 (commit 469d374, 2026-05-12) 通过引入
已应用到全部 6 个支付控制器(topup / topup_stripe / topup_waffo / topup_waffo_pancake / subscription_payment_epay / subscription_payment_stripe),比本 PR 的方案更优雅。 故关闭本 PR,问题已通过上游实现解决。 |
Problem
The default frontend (v1) introduced in
v1.0.0-rc.1reorganized routes to drop the/console/prefix:/console/log/usage-logs/console/topup/walletBut payment-related controllers (
controller/topup.go,controller/topup_stripe.go) still hardcode the classic paths for return / success / cancel URLs. This causes a 404 in the v1 UI after the user completes payment, since the v1 router does not recognize/console/logor/console/topup.Reproduction (with default frontend active):
Fix
Select the appropriate path at request time based on
common.GetTheme(). Classic paths remain the fallback so existing classic deployments are unaffected.common.GetTheme()reads an atomic value updated when the admin toggles the frontend in 设置 → 其他设置 → 切换到新版前端, so the change takes effect immediately without restarting.Affected URLs
controller/topup.go/console/log/usage-logscontroller/topup_stripe.go/console/log/usage-logscontroller/topup_stripe.go/console/topup/walletTested
theme.frontend=default./usage-logs(HTTP 200) showing the new top-up record. Async notify and quota credit work end-to-end.go build ./controller/.Compatibility
success_url/cancel_urloverrides on Stripe still take precedence; the conditional only affects the empty-URL fallback.