mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 21:32:10 +03:00
fix(proxy): show registry provider proxies in dashboard (#2963)
Integrated into release/v3.8.8
This commit is contained in:
@@ -1619,6 +1619,19 @@ export default function ProviderDetailPage() {
|
||||
}
|
||||
}, [providerId, isSearchProvider]);
|
||||
|
||||
const fetchProxyConfig = useCallback(async () => {
|
||||
try {
|
||||
const res = await fetch("/api/settings/proxy", { cache: "no-store" });
|
||||
if (res.ok) {
|
||||
setProxyConfig(await res.json());
|
||||
} else {
|
||||
setProxyConfig(null);
|
||||
}
|
||||
} catch {
|
||||
// Proxy indicators are best-effort.
|
||||
}
|
||||
}, []);
|
||||
|
||||
const fetchConnections = useCallback(async () => {
|
||||
try {
|
||||
const [connectionsRes, nodesRes] = await Promise.all([
|
||||
@@ -1680,11 +1693,8 @@ export default function ProviderDetailPage() {
|
||||
fetchConnections();
|
||||
fetchAliases();
|
||||
// Load proxy config for visual indicators (provider-level button)
|
||||
fetch("/api/settings/proxy")
|
||||
.then((r) => (r.ok ? r.json() : null))
|
||||
.then((c) => setProxyConfig(c))
|
||||
.catch(() => {});
|
||||
}, [fetchConnections, fetchAliases]);
|
||||
void fetchProxyConfig();
|
||||
}, [fetchConnections, fetchAliases, fetchProxyConfig]);
|
||||
|
||||
const handleZedImport = useCallback(async () => {
|
||||
if (importingZed) return;
|
||||
@@ -4895,7 +4905,10 @@ export default function ProviderDetailPage() {
|
||||
level={proxyTarget.level}
|
||||
levelId={proxyTarget.id}
|
||||
levelLabel={proxyTarget.label}
|
||||
onSaved={() => void loadConnProxies(connections)}
|
||||
onSaved={() => {
|
||||
void fetchProxyConfig();
|
||||
void loadConnProxies(connections);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{/* Import Progress Modal */}
|
||||
|
||||
@@ -160,6 +160,30 @@ export async function GET(request: Request) {
|
||||
return Response.json({ level, id, proxy });
|
||||
}
|
||||
|
||||
if (level === "provider" && id) {
|
||||
const assignments = await getProxyAssignments({ scope: "provider" });
|
||||
const assignment = assignments.find((entry) => entry.scopeId === id);
|
||||
if (assignment?.proxyId) {
|
||||
const proxyData = await getProxyById(assignment.proxyId, { includeSecrets: true });
|
||||
if (proxyData) {
|
||||
return Response.json({
|
||||
level,
|
||||
id,
|
||||
proxy: {
|
||||
type: proxyData.type,
|
||||
host: proxyData.host,
|
||||
port: proxyData.port,
|
||||
username: proxyData.username,
|
||||
password: proxyData.password,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const proxy = await getProxyForLevel(level, id);
|
||||
return Response.json({ level, id, proxy });
|
||||
}
|
||||
|
||||
if (level) {
|
||||
const proxy = await getProxyForLevel(level, id);
|
||||
return Response.json({ level, id, proxy });
|
||||
@@ -167,6 +191,24 @@ export async function GET(request: Request) {
|
||||
|
||||
// Get full config
|
||||
const config = await getProxyConfig();
|
||||
const providerAssignments = await getProxyAssignments({ scope: "provider" });
|
||||
if (providerAssignments.length > 0) {
|
||||
config.providers = { ...(config.providers || {}) };
|
||||
for (const assignment of providerAssignments) {
|
||||
if (!assignment.scopeId || !assignment.proxyId) {
|
||||
continue;
|
||||
}
|
||||
const proxyData = await getProxyById(assignment.proxyId, { includeSecrets: true });
|
||||
if (!proxyData) continue;
|
||||
config.providers[assignment.scopeId] = {
|
||||
type: proxyData.type,
|
||||
host: proxyData.host,
|
||||
port: proxyData.port,
|
||||
username: proxyData.username,
|
||||
password: proxyData.password,
|
||||
};
|
||||
}
|
||||
}
|
||||
return Response.json(config);
|
||||
} catch (error) {
|
||||
return createErrorResponseFromUnknown(error, "Failed to load proxy config");
|
||||
|
||||
Reference in New Issue
Block a user