This commit is contained in:
Timothy Jaeryang Baek
2026-03-26 18:17:49 -05:00
parent a641325707
commit 4567cdc0d9
3 changed files with 56 additions and 14 deletions
+14 -13
View File
@@ -268,9 +268,10 @@ export const detectTerminalServerType = async (
/**
* Create or update a policy on the orchestrator.
* PUT {url}/api/v1/policies/{policyId}
* Proxied through the Open WebUI backend to keep API keys server-side.
*/
export const putOrchestratorPolicy = async (
token: string,
url: string,
key: string,
policyId: string,
@@ -278,18 +279,18 @@ export const putOrchestratorPolicy = async (
): Promise<object | null> => {
let error = null;
const baseUrl = url.replace(/\/$/, '');
const headers: Record<string, string> = {
'Content-Type': 'application/json'
};
if (key) {
headers['Authorization'] = `Bearer ${key}`;
}
const res = await fetch(`${baseUrl}/api/v1/policies/${encodeURIComponent(policyId)}`, {
method: 'PUT',
headers,
body: JSON.stringify(policyData)
const res = await fetch(`${WEBUI_API_BASE_URL}/configs/terminal_servers/policy`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify({
url: url.replace(/\/$/, ''),
key,
policy_id: policyId,
policy_data: policyData
})
})
.then(async (res) => {
if (!res.ok) throw await res.json();
@@ -198,7 +198,7 @@
// Save policy to orchestrator if applicable
if (serverType === 'orchestrator' && !direct && policyId) {
try {
await putOrchestratorPolicy(url, key, policyId, buildPolicyData());
await putOrchestratorPolicy(localStorage.token, url, key, policyId, buildPolicyData());
} catch (err) {
toast.error($i18n.t('Failed to save policy: {{error}}', { error: err }));
return;