Change: preserve trailing slash in custom api calls (#5410)

This commit is contained in:
shamoon 2025-06-10 16:02:48 -07:00 committed by GitHub
parent a64c83209a
commit 6e16adc460
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 ?? {};