mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
refactor(proxy): rely on auth header instead (#9422)
* refactor(proxy): rely on auth header instead * chore: typo * chore: language Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * chore: more language Co-authored-by: Aura Román <kyradiscord@gmail.com> * chore: more language nitpicks Co-authored-by: ckohen <chaikohen@gmail.com> * fix: unnecessary async --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Aura Román <kyradiscord@gmail.com> Co-authored-by: ckohen <chaikohen@gmail.com>
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
|
||||
Quickly spin up an instance:
|
||||
|
||||
`docker run -d --restart unless-stopped --name proxy -p 127.0.0.1:8080:8080 -e DISCORD_TOKEN=abc discordjs/proxy`
|
||||
`docker run -d --restart unless-stopped --name proxy -p 127.0.0.1:8080:8080 discordjs/proxy`
|
||||
|
||||
Use it:
|
||||
|
||||
@@ -48,6 +48,9 @@ const rest = new REST({
|
||||
});
|
||||
```
|
||||
|
||||
**Do note that you should not use the same proxy with multiple bots. We cannot guarantee you won't hit rate limits.
|
||||
Webhooks with tokens or other requests that don't include the Authorization header are okay, though!**
|
||||
|
||||
## Links
|
||||
|
||||
- [Website][website] ([source][website-source])
|
||||
|
||||
@@ -3,12 +3,8 @@ import process from 'node:process';
|
||||
import { proxyRequests } from '@discordjs/proxy';
|
||||
import { REST } from '@discordjs/rest';
|
||||
|
||||
if (!process.env.DISCORD_TOKEN) {
|
||||
throw new Error('A DISCORD_TOKEN env var is required');
|
||||
}
|
||||
|
||||
// We want to let upstream handle retrying
|
||||
const api = new REST({ rejectOnRateLimit: () => true, retries: 0 }).setToken(process.env.DISCORD_TOKEN);
|
||||
const api = new REST({ rejectOnRateLimit: () => true, retries: 0 });
|
||||
const server = createServer(proxyRequests(api));
|
||||
|
||||
const port = Number.parseInt(process.env.PORT ?? '8080', 10);
|
||||
|
||||
Reference in New Issue
Block a user