Skip to content

Commit 7977aaa

Browse files
crivetimihaiclaude
andcommitted
Fix passthrough headers not saving in add forms
- Add missing passthrough_headers field to DbGateway creation in register_gateway() - Add method="POST" to add-tool-form, add-resource-form, and add-gateway-form - Standardize all add form handlers to use fetch() instead of fetchWithTimeout() - Remove redirect: "manual" option that was interfering with form responses 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c9fffb8 commit 7977aaa

File tree

3 files changed

+26
-44
lines changed

3 files changed

+26
-44
lines changed

mcpgateway/services/gateway_service.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ async def register_gateway(
560560
auth_type=auth_type,
561561
auth_value=auth_value,
562562
oauth_config=oauth_config,
563+
passthrough_headers=gateway.passthrough_headers,
563564
tools=tools,
564565
resources=db_resources,
565566
prompts=db_prompts,
@@ -897,12 +898,9 @@ async def update_gateway(self, db: Session, gateway_id: str, gateway_update: Gat
897898
parsed = [h.strip() for h in gateway_update.passthrough_headers.split(",") if h.strip()]
898899
gateway.passthrough_headers = parsed
899900
else:
900-
raise GatewayError(
901-
"Invalid passthrough_headers format: must be list[str] or comma-separated string")
901+
raise GatewayError("Invalid passthrough_headers format: must be list[str] or comma-separated string")
902902

903-
logger.info(
904-
"Updated passthrough_headers for gateway {gateway.id}: {gateway.passthrough_headers}"
905-
)
903+
logger.info("Updated passthrough_headers for gateway {gateway.id}: {gateway.passthrough_headers}")
906904

907905
if getattr(gateway, "auth_type", None) is not None:
908906
gateway.auth_type = gateway_update.auth_type

mcpgateway/static/admin.js

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6903,13 +6903,10 @@ async function handleGatewayFormSubmit(e) {
69036903
formData.append("oauth_config", JSON.stringify(oauthConfig));
69046904
}
69056905

6906-
const response = await fetchWithTimeout(
6907-
`${window.ROOT_PATH}/admin/gateways`,
6908-
{
6909-
method: "POST",
6910-
body: formData,
6911-
},
6912-
);
6906+
const response = await fetch(`${window.ROOT_PATH}/admin/gateways`, {
6907+
method: "POST",
6908+
body: formData,
6909+
});
69136910
const result = await response.json();
69146911

69156912
if (!result || !result.success) {
@@ -6967,13 +6964,10 @@ async function handleResourceFormSubmit(e) {
69676964
const isInactiveCheckedBool = isInactiveChecked("resources");
69686965
formData.append("is_inactive_checked", isInactiveCheckedBool);
69696966

6970-
const response = await fetchWithTimeout(
6971-
`${window.ROOT_PATH}/admin/resources`,
6972-
{
6973-
method: "POST",
6974-
body: formData,
6975-
},
6976-
);
6967+
const response = await fetch(`${window.ROOT_PATH}/admin/resources`, {
6968+
method: "POST",
6969+
body: formData,
6970+
});
69776971
const result = await response.json();
69786972
if (!result || !result.success) {
69796973
throw new Error(result?.message || "Failed to add Resource");
@@ -7025,13 +7019,10 @@ async function handlePromptFormSubmit(e) {
70257019
const isInactiveCheckedBool = isInactiveChecked("prompts");
70267020
formData.append("is_inactive_checked", isInactiveCheckedBool);
70277021

7028-
const response = await fetchWithTimeout(
7029-
`${window.ROOT_PATH}/admin/prompts`,
7030-
{
7031-
method: "POST",
7032-
body: formData,
7033-
},
7034-
);
7022+
const response = await fetch(`${window.ROOT_PATH}/admin/prompts`, {
7023+
method: "POST",
7024+
body: formData,
7025+
});
70357026
const result = await response.json();
70367027
if (!result || !result.success) {
70377028
throw new Error(result?.message || "Failed to add prompt");
@@ -7131,14 +7122,10 @@ async function handleServerFormSubmit(e) {
71317122
const isInactiveCheckedBool = isInactiveChecked("servers");
71327123
formData.append("is_inactive_checked", isInactiveCheckedBool);
71337124

7134-
const response = await fetchWithTimeout(
7135-
`${window.ROOT_PATH}/admin/servers`,
7136-
{
7137-
method: "POST",
7138-
body: formData,
7139-
redirect: "manual",
7140-
},
7141-
);
7125+
const response = await fetch(`${window.ROOT_PATH}/admin/servers`, {
7126+
method: "POST",
7127+
body: formData,
7128+
});
71427129
const result = await response.json();
71437130
if (!result || !result.success) {
71447131
throw new Error(result?.message || "Failed to add server.");
@@ -7214,13 +7201,10 @@ async function handleToolFormSubmit(event) {
72147201
const isInactiveCheckedBool = isInactiveChecked("tools");
72157202
formData.append("is_inactive_checked", isInactiveCheckedBool);
72167203

7217-
const response = await fetchWithTimeout(
7218-
`${window.ROOT_PATH}/admin/tools`,
7219-
{
7220-
method: "POST",
7221-
body: formData,
7222-
},
7223-
);
7204+
const response = await fetch(`${window.ROOT_PATH}/admin/tools`, {
7205+
method: "POST",
7206+
body: formData,
7207+
});
72247208
const result = await response.json();
72257209
if (!result || !result.success) {
72267210
throw new Error(result?.message || "Failed to add tool");

mcpgateway/templates/admin.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,7 +2383,7 @@ <h3 class="text-lg font-bold dark:text-gray-200">Add New Tool from REST API</h3>
23832383
</div>
23842384
</div>
23852385

2386-
<form id="add-tool-form">
2386+
<form method="POST" id="add-tool-form">
23872387
<div class="grid grid-cols-1 gap-6">
23882388
<div>
23892389
<label
@@ -3018,7 +3018,7 @@ <h2 class="text-2xl font-bold dark:text-gray-200">MCP Resources</h2>
30183018
<h3 class="text-lg font-bold mb-4 dark:text-gray-200">
30193019
Add New Resource
30203020
</h3>
3021-
<form id="add-resource-form">
3021+
<form method="POST" id="add-resource-form">
30223022
<div class="grid grid-cols-1 gap-6">
30233023
<div>
30243024
<label
@@ -3820,7 +3820,7 @@ <h2 class="text-2xl font-bold dark:text-gray-200">
38203820
<h3 class="text-lg font-bold mb-4 dark:text-gray-200">
38213821
Add New MCP Server or Gateway
38223822
</h3>
3823-
<form id="add-gateway-form">
3823+
<form method="POST" id="add-gateway-form">
38243824
<div class="grid grid-cols-1 gap-6">
38253825
<div>
38263826
<label

0 commit comments

Comments
 (0)