From 6e16adc460909c90b479070700ce55b58dbd1ea1 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 10 Jun 2025 16:02:48 -0700 Subject: [PATCH] Change: preserve trailing slash in custom api calls (#5410) --- src/utils/proxy/handlers/generic.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/proxy/handlers/generic.js b/src/utils/proxy/handlers/generic.js index 1914114c2..166dc145c 100644 --- a/src/utils/proxy/handlers/generic.js +++ b/src/utils/proxy/handlers/generic.js @@ -19,9 +19,11 @@ export default async function genericProxyHandler(req, res, map) { if (widget) { // if there are more than one question marks, replace others to & - const url = new URL( - formatApiCall(widgets[widget.type].api, { endpoint, ...widget }).replace(/(?<=\?.*)\?/g, "&"), - ); + let urlString = formatApiCall(widgets[widget.type].api, { endpoint, ...widget }).replace(/(?<=\?.*)\?/g, "&"); + if (widget.type === "customapi" && widget.url?.endsWith("/")) { + urlString += "/"; // Ensure we dont lose the trailing slash for custom API calls + } + const url = new URL(urlString); const headers = req.extraHeaders ?? widget.headers ?? widgets[widget.type].headers ?? {};