Skip to content

Commit

Permalink
fix(proxyRequests): forward query parameters (#8691)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
didinele and kodiakhq[bot] committed Oct 1, 2022
1 parent 6398e46 commit f063625
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/proxy/src/handlers/proxyRequests.ts
Expand Up @@ -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({
Expand All @@ -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']!,
},
Expand Down

0 comments on commit f063625

Please sign in to comment.