agent v0.3.15: mode proxy auto/manuel, correction auto-update et conservation systray, animation UI update
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getAgentVersionInfo } from "@/lib/agent-version";
|
||||
import { getAgentVersionInfo, getBaseUrlFromRequest } from "@/lib/agent-version";
|
||||
|
||||
export async function GET() {
|
||||
return NextResponse.json(getAgentVersionInfo());
|
||||
export async function GET(request: Request) {
|
||||
const baseUrl = getBaseUrlFromRequest(request);
|
||||
return NextResponse.json(getAgentVersionInfo(baseUrl));
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getAgentVersionInfo } from "@/lib/agent-version";
|
||||
import { getAgentVersionInfo, getBaseUrlFromRequest } from "@/lib/agent-version";
|
||||
|
||||
export async function GET() {
|
||||
const info = getAgentVersionInfo();
|
||||
export async function GET(request: Request) {
|
||||
const baseUrl = getBaseUrlFromRequest(request);
|
||||
const info = getAgentVersionInfo(baseUrl);
|
||||
return NextResponse.json({
|
||||
version: info.version,
|
||||
windows: info.downloadUrls.windows,
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
|
||||
import { getAgentVersionInfo } from "@/lib/agent-version";
|
||||
import { getAgentVersionInfo, getBaseUrlFromRequest } from "@/lib/agent-version";
|
||||
import { headers } from "next/headers";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default function DownloadPage() {
|
||||
const info = getAgentVersionInfo();
|
||||
export default async function DownloadPage() {
|
||||
const h = await headers();
|
||||
const proto = h.get("x-forwarded-proto") ?? "https";
|
||||
const host = h.get("x-forwarded-host") ?? h.get("host") ?? "";
|
||||
const baseUrl = host ? `${proto}://${host}` : undefined;
|
||||
const info = getAgentVersionInfo(baseUrl);
|
||||
const { version, downloadUrls } = info;
|
||||
|
||||
return (
|
||||
|
||||
@@ -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