From f063625836915b0fa3b0f0b89d073e877465dfd4 Mon Sep 17 00:00:00 2001 From: DD Date: Sat, 1 Oct 2022 16:46:52 +0300 Subject: [PATCH] fix(proxyRequests): forward query parameters (#8691) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/proxy/src/handlers/proxyRequests.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/proxy/src/handlers/proxyRequests.ts b/packages/proxy/src/handlers/proxyRequests.ts index 1efb8601f355..5f4704efb96a 100644 --- a/packages/proxy/src/handlers/proxyRequests.ts +++ b/packages/proxy/src/handlers/proxyRequests.ts @@ -32,8 +32,9 @@ export function proxyRequests(rest: REST): RequestHandler { // The 2nd parameter is here so the URL constructor doesn't complain about an "invalid url" when the origin is missing // we don't actually care about the origin and the value passed is irrelevant - // eslint-disable-next-line prefer-named-capture-group, unicorn/no-unsafe-regex - const fullRoute = new URL(url, 'http://noop').pathname.replace(/^\/api(\/v\d+)?/, '') as RouteLike; + const parsedUrl = new URL(url, 'http://noop'); + // eslint-disable-next-line unicorn/no-unsafe-regex, prefer-named-capture-group + const fullRoute = parsedUrl.pathname.replace(/^\/api(\/v\d+)?/, '') as RouteLike; try { const discordResponse = await rest.raw({ @@ -42,6 +43,7 @@ export function proxyRequests(rest: REST): RequestHandler { // This type cast is technically incorrect, but we want Discord to throw Method Not Allowed for us method: method as RequestMethod, passThroughBody: true, + query: parsedUrl.searchParams, headers: { 'Content-Type': req.headers['content-type']!, },