mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 09:01:17 +00:00
Add Railway Caddy frontend images
This commit is contained in:
parent
940e49fcfa
commit
e79a3d9389
6 changed files with 107 additions and 4 deletions
|
|
@ -18,6 +18,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="/__foundry_runtime_config.js"></script>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,15 @@
|
|||
type FoundryRuntimeConfig = {
|
||||
backendEndpoint?: string;
|
||||
defaultWorkspaceId?: string;
|
||||
frontendClientMode?: string;
|
||||
};
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__FOUNDRY_RUNTIME_CONFIG__?: FoundryRuntimeConfig;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveDefaultBackendEndpoint(): string {
|
||||
if (typeof window !== "undefined" && window.location?.origin) {
|
||||
return `${window.location.origin}/api/rivet`;
|
||||
|
|
@ -10,20 +22,23 @@ type FrontendImportMetaEnv = ImportMetaEnv & {
|
|||
};
|
||||
|
||||
const frontendEnv = import.meta.env as FrontendImportMetaEnv;
|
||||
const runtimeConfig = typeof window !== "undefined" ? window.__FOUNDRY_RUNTIME_CONFIG__ : undefined;
|
||||
|
||||
export const backendEndpoint = import.meta.env.VITE_HF_BACKEND_ENDPOINT?.trim() || resolveDefaultBackendEndpoint();
|
||||
export const backendEndpoint = runtimeConfig?.backendEndpoint?.trim() || import.meta.env.VITE_HF_BACKEND_ENDPOINT?.trim() || resolveDefaultBackendEndpoint();
|
||||
|
||||
export const defaultWorkspaceId = import.meta.env.VITE_HF_WORKSPACE?.trim() || "default";
|
||||
export const defaultWorkspaceId = runtimeConfig?.defaultWorkspaceId?.trim() || import.meta.env.VITE_HF_WORKSPACE?.trim() || "default";
|
||||
|
||||
function resolveFrontendClientMode(): "mock" | "remote" {
|
||||
const raw = frontendEnv.FOUNDRY_FRONTEND_CLIENT_MODE?.trim().toLowerCase();
|
||||
const raw = runtimeConfig?.frontendClientMode?.trim().toLowerCase() || frontendEnv.FOUNDRY_FRONTEND_CLIENT_MODE?.trim().toLowerCase();
|
||||
if (raw === "mock") {
|
||||
return "mock";
|
||||
}
|
||||
if (raw === "remote" || raw === "" || raw === undefined) {
|
||||
return "remote";
|
||||
}
|
||||
throw new Error(`Unsupported FOUNDRY_FRONTEND_CLIENT_MODE value "${frontendEnv.FOUNDRY_FRONTEND_CLIENT_MODE}". Expected "mock" or "remote".`);
|
||||
throw new Error(
|
||||
`Unsupported FOUNDRY_FRONTEND_CLIENT_MODE value "${runtimeConfig?.frontendClientMode ?? frontendEnv.FOUNDRY_FRONTEND_CLIENT_MODE}". Expected "mock" or "remote".`,
|
||||
);
|
||||
}
|
||||
|
||||
export const frontendClientMode = resolveFrontendClientMode();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue