mirror of
https://github.com/fosrl/pangolin.git
synced 2026-06-12 10:27:06 +00:00
use resource name in ssh/rdp/vnc page meta
This commit is contained in:
20
src/lib/getBrowserTargetForRequest.ts
Normal file
20
src/lib/getBrowserTargetForRequest.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { priv } from "@app/lib/api";
|
||||
import { GetBrowserTargetResponse } from "@server/routers/browserGatewayTarget";
|
||||
import { AxiosResponse } from "axios";
|
||||
import { headers } from "next/headers";
|
||||
import { cache } from "react";
|
||||
|
||||
export const getBrowserTargetForRequest = cache(async () => {
|
||||
const headersList = await headers();
|
||||
const host = headersList.get("host") || "";
|
||||
const hostname = host.split(":")[0];
|
||||
|
||||
try {
|
||||
const res = await priv.get<AxiosResponse<GetBrowserTargetResponse>>(
|
||||
`/resource/browser-target?fullDomain=${encodeURIComponent(hostname)}`
|
||||
);
|
||||
return { target: res.data.data };
|
||||
} catch {
|
||||
return { target: null };
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user