fix(topup): use theme-aware return URLs for epay and stripe#4620
fix(topup): use theme-aware return URLs for epay and stripe#4620pholex wants to merge 1 commit intoQuantumNous:mainfrom
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 |
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.