Skip to content

spinfal/cdn-slave

Repository files navigation

CDN Slave status CDN Slave uptime

Updates

https://blog.spin.rip/p/discord-cdn-changes

CDN Slave

A simple website that allows you to upload files to Discord's CDN without having to do it in their app.

Prerequisites

Node.js

Discord Bot

Git (optional)

Installation

Run this command:

git clone https://github.com/spinfal/cdn-slave.git

or download the ZIP file and extract it

cd cdn-slave

Follow these steps:

  • Rename Global.example.js to Global.js
  • Go to https://discord.com/developers/applications and create bot
  • Make sure this is enabled Message Content Intent
  • Invite the bot to your server using this link: https://discord.com/api/oauth2/authorize?client_id=INSERT YOUR APPLICATION ID&permissions=52224&scope=bot
  • Configure the Global.js file (bot, channel, and database settings)

Continue with running these commands:

npm i
npm run setup

This creates Global.js if missing, initializes the SQLite database, and builds CSS.

npm run db:init

If you skip setup, run db:init manually.

npm run start

or

npm run dev

Usage

The website will be up @ http://localhost:443 (unless you've changed the config)

Files uploaded on the site will be available in the channel that you set in Global.js

If you want custom URLs to point at your domain, set publicUrl in Global.js.

Database

SQLite stores data in a local file at data/cdn-slave.sqlite by default. To move it elsewhere, update database.filename in Global.js.

Upload Controls

Uploads use the size limit from maxFileSize and run through rate limiting, MIME checks, and concurrency caps. Adjust these settings in Global.js:

  • upload.rateLimit.windowMs and upload.rateLimit.max (per-IP requests)
  • upload.maxConcurrent (simultaneous uploads)
  • upload.allowedMimeTypes and upload.allowedMimePrefixes
  • upload.tempDir (where temporary upload files are stored)

The defaults allow common media formats plus PDF/ZIP. Update the allow lists if you want other file types. Set both allow lists to empty arrays if you want to accept any MIME type.

Health Check

GET /health returns {"status":"ok"} when the server and database are reachable.

Other Settings

logLevel controls server logging verbosity, and defaultTimezone is used as the fallback for server-side timestamps before the browser converts them to the viewer's timezone.

Usage with ShareX

CDN Slave can also be used with ShareX! Follow these steps to get it working (don't want to follow steps? click here to download the config):

  1. Copy the upload endpoint. If using localhost it will be http://localhost:443/api/upload, or if you're using my instance it will be https://cdn-slave.spin.rip/api/upload
  2. Open ShareX and go to Destinations > Custom uploader settings > Click New
  3. Name it whatever you want & paste the upload endpoint in Request URL
  4. Under Destination type, select Image uploader, Text uploader, and File uploader
  5. Body should be Form data (multipart/form-data) and File form name should just be file.
  6. In the headers section, set the name to Upload-Source and the value to API
  7. Select your new ShareX config in the dropdowns at the bottom left of your screen
  8. Have fun with your new CDN slave. ShareX CDN Slave GIF tutorial

About

A simple website that allows you to upload files to Discord's CDN without having to do it in their app.

Topics

Resources

License

Stars

Watchers

Forks

Contributors