mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 08:03:46 +00:00
Fix Foundry Rivet base path and frontend endpoint fallback
This commit is contained in:
parent
9a2c60bf30
commit
a8bcfa36bb
3 changed files with 24 additions and 2 deletions
|
|
@ -5,9 +5,20 @@ escape_js() {
|
|||
printf '%s' "${1:-}" | sed 's/\\/\\\\/g; s/"/\\"/g'
|
||||
}
|
||||
|
||||
normalize_backend_endpoint() {
|
||||
case "${1:-}" in
|
||||
*/api/rivet)
|
||||
printf '%s/v1/rivet' "${1%/api/rivet}"
|
||||
;;
|
||||
*)
|
||||
printf '%s' "${1:-}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cat > /srv/__foundry_runtime_config.js <<EOF
|
||||
window.__FOUNDRY_RUNTIME_CONFIG__ = {
|
||||
backendEndpoint: "$(escape_js "${VITE_HF_BACKEND_ENDPOINT:-}")",
|
||||
backendEndpoint: "$(escape_js "$(normalize_backend_endpoint "${VITE_HF_BACKEND_ENDPOINT:-}")")",
|
||||
defaultWorkspaceId: "$(escape_js "${VITE_HF_WORKSPACE:-}")",
|
||||
frontendClientMode: "$(escape_js "${FOUNDRY_FRONTEND_CLIENT_MODE:-remote}")"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ import { sandboxInstance } from "./sandbox-instance/index.js";
|
|||
import { workspace } from "./workspace/index.js";
|
||||
|
||||
export const registry = setup({
|
||||
serverless: {
|
||||
basePath: "/v1/rivet",
|
||||
},
|
||||
use: {
|
||||
workspace,
|
||||
project,
|
||||
|
|
|
|||
|
|
@ -273,8 +273,16 @@ function stripTrailingSlash(value: string): string {
|
|||
return value.replace(/\/$/, "");
|
||||
}
|
||||
|
||||
function deriveBackendEndpoints(endpoint: string): { appEndpoint: string; rivetEndpoint: string } {
|
||||
function normalizeLegacyBackendEndpoint(endpoint: string): string {
|
||||
const normalized = stripTrailingSlash(endpoint);
|
||||
if (normalized.endsWith("/api/rivet")) {
|
||||
return `${normalized.slice(0, -"/api/rivet".length)}/v1/rivet`;
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function deriveBackendEndpoints(endpoint: string): { appEndpoint: string; rivetEndpoint: string } {
|
||||
const normalized = normalizeLegacyBackendEndpoint(endpoint);
|
||||
if (normalized.endsWith("/rivet")) {
|
||||
return {
|
||||
appEndpoint: normalized.slice(0, -"/rivet".length),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue