fix: Admin Panel health checks work via reverse proxy
- loadServiceUrls: use window.location.origin for remote access, localhost for local dev - testCoreApi: use /api/v1/health for remote, /health for localhost - testProxy: health check path works for both - testMbe: already uses getApiBase() which handles both cases This fixes the issue where Admin Panel showed offline when accessed via https://nextorage.momentry.ddns.net because localhost health checks point to user's machine, not the server.
This commit is contained in:
@@ -799,12 +799,17 @@ function serviceState(name: string) {
|
|||||||
|
|
||||||
function loadServiceUrls() {
|
function loadServiceUrls() {
|
||||||
const stored = localStorage.getItem('service_urls')
|
const stored = localStorage.getItem('service_urls')
|
||||||
// Always use localhost for services - they run on the same machine
|
// Use current origin for services - works both locally and via reverse proxy
|
||||||
const defaultCore = 'http://localhost:3002'
|
const currentOrigin = window.location.origin
|
||||||
const defaultMarkbase = 'http://localhost:11438'
|
const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
|
||||||
const defaultMbe = 'http://localhost:8080'
|
|
||||||
const defaultProxy = 'http://localhost:8888'
|
// Local dev: use direct localhost ports
|
||||||
const defaultWorker = 'http://localhost:11438'
|
// Remote access: use current origin (reverse proxy forwards requests)
|
||||||
|
const defaultCore = isLocalhost ? 'http://localhost:3002' : currentOrigin
|
||||||
|
const defaultMarkbase = isLocalhost ? 'http://localhost:11438' : currentOrigin
|
||||||
|
const defaultMbe = isLocalhost ? 'http://localhost:8080' : currentOrigin
|
||||||
|
const defaultProxy = isLocalhost ? 'http://localhost:8888' : currentOrigin
|
||||||
|
const defaultWorker = isLocalhost ? 'http://localhost:11438' : currentOrigin
|
||||||
|
|
||||||
if (stored) {
|
if (stored) {
|
||||||
try {
|
try {
|
||||||
@@ -856,8 +861,10 @@ async function testCoreApi() {
|
|||||||
testingCore.value = true
|
testingCore.value = true
|
||||||
coreInfo.value = null
|
coreInfo.value = null
|
||||||
try {
|
try {
|
||||||
// Core API directly serves /health on localhost
|
const isLocalhost = coreApiUrl.value.includes('localhost') || coreApiUrl.value.includes('127.0.0.1')
|
||||||
const healthUrl = `${coreApiUrl.value}/health`
|
// Localhost: direct /health path
|
||||||
|
// Remote: via reverse proxy at /api/v1/health
|
||||||
|
const healthUrl = isLocalhost ? `${coreApiUrl.value}/health` : `${coreApiUrl.value}/api/v1/health`
|
||||||
const resp = await fetch(healthUrl, { signal: AbortSignal.timeout(5000) })
|
const resp = await fetch(healthUrl, { signal: AbortSignal.timeout(5000) })
|
||||||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
|
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
|
||||||
const data = await resp.json()
|
const data = await resp.json()
|
||||||
@@ -935,6 +942,9 @@ async function testMbe() {
|
|||||||
async function testProxy() {
|
async function testProxy() {
|
||||||
testingProxy.value = true
|
testingProxy.value = true
|
||||||
try {
|
try {
|
||||||
|
const isLocalhost = proxyUrl.value.includes('localhost') || proxyUrl.value.includes('127.0.0.1')
|
||||||
|
// Localhost: direct /health path
|
||||||
|
// Remote: via reverse proxy at /health (same path)
|
||||||
const healthUrl = `${proxyUrl.value}/health`
|
const healthUrl = `${proxyUrl.value}/health`
|
||||||
const resp = await fetch(healthUrl, { signal: AbortSignal.timeout(5000) })
|
const resp = await fetch(healthUrl, { signal: AbortSignal.timeout(5000) })
|
||||||
proxyStatus.value = resp.ok ? 'online' : 'offline'
|
proxyStatus.value = resp.ok ? 'online' : 'offline'
|
||||||
|
|||||||
Reference in New Issue
Block a user