fix: preserve service ID on subdomain change, accept localhost as IP
- serviceUrl() now checks service.url before falling back to buildServiceUrl(id) - Service update no longer overwrites ID with the new subdomain - Accept "localhost" as valid IP in service update validation - Find services by ID or URL match when updating Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -422,7 +422,7 @@ module.exports = function(ctx) {
|
||||
return ctx.errorResponse(res, 400, 'Invalid port number (must be 1-65535)');
|
||||
}
|
||||
|
||||
if (ip && !validatorLib.isIP(ip)) {
|
||||
if (ip && ip !== 'localhost' && !validatorLib.isIP(ip)) {
|
||||
return ctx.errorResponse(res, 400, '[DC-210] Invalid IP address');
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ module.exports = function(ctx) {
|
||||
|
||||
if (await exists(ctx.SERVICES_FILE)) {
|
||||
await ctx.servicesStateManager.update(services => {
|
||||
const serviceIndex = services.findIndex(s => s.id === oldSubdomain);
|
||||
const serviceIndex = services.findIndex(s => s.id === oldSubdomain || s.url?.includes(oldSubdomain));
|
||||
if (serviceIndex !== -1) {
|
||||
const existing = services[serviceIndex];
|
||||
const finalPort = port || existing.port;
|
||||
@@ -481,7 +481,7 @@ module.exports = function(ctx) {
|
||||
|
||||
services[serviceIndex] = {
|
||||
...existing,
|
||||
id: newSubdomain,
|
||||
// Keep the original ID — don't change it to the subdomain
|
||||
port: finalPort,
|
||||
ip: finalIp,
|
||||
tailscaleOnly: tailscaleOnly || false,
|
||||
|
||||
141
status/dist/core.js
vendored
141
status/dist/core.js
vendored
File diff suppressed because one or more lines are too long
@@ -77,7 +77,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
function serviceUrl(id) { return buildServiceUrl(id); }
|
||||
function serviceUrl(id) {
|
||||
const svc = window.APPS?.find(a => a.id === id);
|
||||
if (svc?.url) return svc.url.startsWith('http') ? svc.url : 'https://' + svc.url;
|
||||
if (svc?.isExternal && svc.externalUrl) return svc.externalUrl;
|
||||
const dns = SITE.dnsServers?.[id];
|
||||
if (dns) return 'http://' + dns.ip + ':' + (dns.port || 5380);
|
||||
return buildServiceUrl(id);
|
||||
}
|
||||
function el(tag, cls, txt) { const n = document.createElement(tag); if (cls) n.className = cls; if (txt) n.textContent = txt; return n; }
|
||||
|
||||
function buildGrid() {
|
||||
|
||||
Reference in New Issue
Block a user