mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-01 08:20:08 +00:00
fix(rest/request_manager): pass authorization header instead (#534)
* fix big brain bot auth on proxy rest * whoops * fix header
This commit is contained in:
@@ -10,6 +10,7 @@ import { baseEndpoints, GATEWAY_VERSION } from "./util/constants.ts";
|
||||
import { spawnShards } from "./ws/shard_manager.ts";
|
||||
|
||||
export let authorization = "";
|
||||
export let restAuthorization = "";
|
||||
export let botID = "";
|
||||
export let applicationID = "";
|
||||
|
||||
@@ -94,6 +95,7 @@ export async function startBigBrainBot(data: BigBrainBotConfig) {
|
||||
authorization = `Bot ${data.token}`;
|
||||
identifyPayload.token = `Bot ${data.token}`;
|
||||
|
||||
if (data.restAuthorization) restAuthorization = data.restAuthorization;
|
||||
if (data.restURL) baseEndpoints.BASE_URL = data.restURL;
|
||||
if (data.cdnURL) baseEndpoints.CDN_URL = data.cdnURL;
|
||||
if (data.wsURL) proxyWSURL = data.wsURL;
|
||||
@@ -133,4 +135,6 @@ export interface BigBrainBotConfig extends BotConfig {
|
||||
restURL?: string;
|
||||
/** This can be used to forward the CDN handling to a proxy. */
|
||||
cdnURL?: string;
|
||||
/** This is the authorization header that your rest proxy will validate */
|
||||
restAuthorization?: string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { authorization, eventHandlers } from "../bot.ts";
|
||||
import { authorization, eventHandlers, restAuthorization } from "../bot.ts";
|
||||
import {
|
||||
Errors,
|
||||
FileContent,
|
||||
@@ -221,7 +221,13 @@ function runMethod(
|
||||
!url.startsWith(`${BASE_URL}/v${API_VERSION}`) &&
|
||||
!url.startsWith(IMAGE_BASE_URL)
|
||||
) {
|
||||
return fetch(url, { method, body: body ? JSON.stringify(body) : undefined })
|
||||
return fetch(url, {
|
||||
method,
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
headers: {
|
||||
authorization: restAuthorization,
|
||||
},
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user