agent v0.3.15: mode proxy auto/manuel, correction auto-update et conservation systray, animation UI update
This commit is contained in:
@@ -3,6 +3,21 @@ import path from "path";
|
||||
|
||||
const BIN_NAME = "studioE5-agent";
|
||||
|
||||
// Build the public base URL from an incoming request, respecting common
|
||||
// reverse-proxy headers (X-Forwarded-Proto / X-Forwarded-Host).
|
||||
export function getBaseUrlFromRequest(req: Request): string {
|
||||
const headers = req.headers;
|
||||
const forwardedProto = headers.get("x-forwarded-proto");
|
||||
const forwardedHost = headers.get("x-forwarded-host");
|
||||
|
||||
if (forwardedProto && forwardedHost) {
|
||||
return `${forwardedProto}://${forwardedHost}`;
|
||||
}
|
||||
|
||||
const url = new URL(req.url);
|
||||
return `${url.protocol}//${url.host}`;
|
||||
}
|
||||
|
||||
function findVersionFile(): string | null {
|
||||
// Try a few common paths relative to the server workspace and Next.js build output.
|
||||
const candidates = [
|
||||
@@ -37,19 +52,23 @@ export interface AgentDownloadUrls {
|
||||
mac: string;
|
||||
}
|
||||
|
||||
export function getAgentDownloadUrls(version: string): AgentDownloadUrls {
|
||||
export function getAgentDownloadUrls(
|
||||
version: string,
|
||||
baseUrl?: string
|
||||
): AgentDownloadUrls {
|
||||
const prefix = baseUrl ? baseUrl.replace(/\/$/, "") : "";
|
||||
return {
|
||||
windows: `/${BIN_NAME}-v${version}.exe`,
|
||||
windowsZip: `/${BIN_NAME}-v${version}-windows.zip`,
|
||||
linux: `/${BIN_NAME}-v${version}`,
|
||||
mac: `/${BIN_NAME}-v${version}-mac`,
|
||||
windows: `${prefix}/${BIN_NAME}-v${version}.exe`,
|
||||
windowsZip: `${prefix}/${BIN_NAME}-v${version}-windows.zip`,
|
||||
linux: `${prefix}/${BIN_NAME}-v${version}`,
|
||||
mac: `${prefix}/${BIN_NAME}-v${version}-mac`,
|
||||
};
|
||||
}
|
||||
|
||||
export function getAgentVersionInfo() {
|
||||
export function getAgentVersionInfo(baseUrl?: string) {
|
||||
const version = getAgentVersion();
|
||||
return {
|
||||
version,
|
||||
downloadUrls: getAgentDownloadUrls(version),
|
||||
downloadUrls: getAgentDownloadUrls(version, baseUrl),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user