fix: 修复仪表盘带宽验证码API路径错误导致网络错误
根因: dashboard页面fetch使用硬编码绝对路径 /bandwidth-send-code, 通过nginx代理 /api/proxy-v3/ 访问时请求到错误路径导致404。 修复: 从window.location.pathname动态提取API前缀,兼容直接访问和代理。 Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/ca70b379-6057-4f7e-b774-e607d7b8bbc6 Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
parent
0c7a4b2369
commit
ae9c987981
|
|
@ -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 })
|
||||
|
|
|
|||
Loading…
Reference in New Issue