mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
fix(proxyRequests): forward query parameters (#8691)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -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
|
// 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
|
// 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 parsedUrl = new URL(url, 'http://noop');
|
||||||
const fullRoute = new URL(url, 'http://noop').pathname.replace(/^\/api(\/v\d+)?/, '') as RouteLike;
|
// eslint-disable-next-line unicorn/no-unsafe-regex, prefer-named-capture-group
|
||||||
|
const fullRoute = parsedUrl.pathname.replace(/^\/api(\/v\d+)?/, '') as RouteLike;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const discordResponse = await rest.raw({
|
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
|
// This type cast is technically incorrect, but we want Discord to throw Method Not Allowed for us
|
||||||
method: method as RequestMethod,
|
method: method as RequestMethod,
|
||||||
passThroughBody: true,
|
passThroughBody: true,
|
||||||
|
query: parsedUrl.searchParams,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': req.headers['content-type']!,
|
'Content-Type': req.headers['content-type']!,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user