Fix local sites

This commit is contained in:
Owen
2025-07-17 14:35:09 -07:00
parent da7166a7ea
commit 330b28ad9c

View File

@@ -42,17 +42,16 @@ export async function traefikConfigProvider(
.from(exitNodes) .from(exitNodes)
.limit(1); .limit(1);
if (!exitNode) { if (exitNode) {
logger.error("No exit node found in the database");
return [];
}
currentExitNodeId = exitNode.exitNodeId; currentExitNodeId = exitNode.exitNodeId;
} }
} }
}
let resourcesWithRelations;
if (currentExitNodeId) {
// Get the site(s) on this exit node // Get the site(s) on this exit node
const resourcesWithRelations = await tx resourcesWithRelations = await tx
.select({ .select({
// Resource fields // Resource fields
resourceId: resources.resourceId, resourceId: resources.resourceId,
@@ -68,7 +67,7 @@ export async function traefikConfigProvider(
siteId: sites.siteId, siteId: sites.siteId,
type: sites.type, type: sites.type,
subnet: sites.subnet, subnet: sites.subnet,
exitNodeId: sites.exitNodeId, exitNodeId: sites.exitNodeId
}, },
enabled: resources.enabled, enabled: resources.enabled,
stickySession: resources.stickySession, stickySession: resources.stickySession,
@@ -78,6 +77,33 @@ export async function traefikConfigProvider(
.from(resources) .from(resources)
.innerJoin(sites, eq(sites.siteId, resources.siteId)) .innerJoin(sites, eq(sites.siteId, resources.siteId))
.where(eq(sites.exitNodeId, currentExitNodeId)); .where(eq(sites.exitNodeId, currentExitNodeId));
} else {
resourcesWithRelations = await tx
.select({
// Resource fields
resourceId: resources.resourceId,
fullDomain: resources.fullDomain,
ssl: resources.ssl,
http: resources.http,
proxyPort: resources.proxyPort,
protocol: resources.protocol,
subdomain: resources.subdomain,
domainId: resources.domainId,
// Site fields
site: {
siteId: sites.siteId,
type: sites.type,
subnet: sites.subnet,
exitNodeId: sites.exitNodeId
},
enabled: resources.enabled,
stickySession: resources.stickySession,
tlsServerName: resources.tlsServerName,
setHostHeader: resources.setHostHeader
})
.from(resources)
.innerJoin(sites, eq(sites.siteId, resources.siteId));
}
// Get all resource IDs from the first query // Get all resource IDs from the first query
const resourceIds = resourcesWithRelations.map((r) => r.resourceId); const resourceIds = resourcesWithRelations.map((r) => r.resourceId);
@@ -284,7 +310,8 @@ export async function traefikConfigProvider(
} else if (site.type === "newt") { } else if (site.type === "newt") {
if ( if (
!target.internalPort || !target.internalPort ||
!target.method || !site.subnet !target.method ||
!site.subnet
) { ) {
return false; return false;
} }