Merge pull request #312 from qinfendebingshuo/copilot/fix-vpn-dashboard-network-error

fix: dashboard bandwidth API fetch uses wrong path through nginx proxy
This commit is contained in:
冰朔 2026-04-08 08:45:49 +08:00 committed by GitHub
commit f13e579089
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 3 deletions

View File

@ -888,6 +888,10 @@ mode: direct
</div>
<script>
// 动态计算API基路径: 通过nginx代理时页面在 /api/proxy-v3/dashboard/{token}
// 直接访问时在 /dashboard/{token},需要提取 /dashboard/ 之前的前缀作为API路径基座
var bwBasePath = window.location.pathname.replace(/\/dashboard\/[a-f0-9]+$/, '');
function bwSendCode() {
var email = document.getElementById('bwEmail').value.trim().toLowerCase();
var btn = document.getElementById('bwSendBtn');
@ -905,7 +909,7 @@ function bwSendCode() {
btn.textContent = '⏳ 发送中...';
result.style.display = 'none';
fetch('/bandwidth-send-code', {
fetch(bwBasePath + '/bandwidth-send-code', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: email })
@ -933,7 +937,7 @@ function bwSendCode() {
result.style.color = '#e74c3c';
}
result.textContent = data.message || (data.success ? '验证码已发送' : '发送失败');
}).catch(function() {
}).catch(function(err) {
btn.disabled = false;
btn.textContent = '📧 发送验证码';
result.style.display = 'block';
@ -976,7 +980,7 @@ function bwVerifyCode() {
btn.textContent = '⏳ 验证中...';
result.style.display = 'none';
fetch('/bandwidth-verify-code', {
fetch(bwBasePath + '/bandwidth-verify-code', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: email, code: code })