diff --git a/.gitignore b/.gitignore index 3c2a16ddd..d5dbd196e 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,5 @@ build *.log *.log.ansi *.tmp -#tmp/ +tmp/ dump/ diff --git a/nginx.conf b/nginx.conf index 61c8e1164..fd4aefcd3 100644 --- a/nginx.conf +++ b/nginx.conf @@ -6,7 +6,6 @@ server { listen 80; location / { - # do NOT change this proxy_pass http://localhost:3001; proxy_set_header Host $host; proxy_pass_request_headers on; @@ -23,4 +22,4 @@ server { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } -} \ No newline at end of file +} diff --git a/src/api/routes/gateway/bot.ts b/src/api/routes/gateway/bot.ts index b8aa6a555..c10afd163 100644 --- a/src/api/routes/gateway/bot.ts +++ b/src/api/routes/gateway/bot.ts @@ -44,7 +44,11 @@ router.get( (req: Request, res: Response) => { const { endpointPublic } = Config.get().gateway; res.json({ - url: websock || "ws://localhost:3001", + url: + endpointPublic || + process.env.GATEWAY || + websock || + "ws://localhost:3001", shards: 1, session_start_limit: { total: 1000, diff --git a/src/api/routes/gateway/index.ts b/src/api/routes/gateway/index.ts index 6986bf29d..c8366d0e4 100644 --- a/src/api/routes/gateway/index.ts +++ b/src/api/routes/gateway/index.ts @@ -44,7 +44,11 @@ router.get( (req: Request, res: Response) => { const { endpointPublic } = Config.get().gateway; res.json({ - url: websock || "ws://localhost:3001", + url: + endpointPublic || + process.env.GATEWAY || + websock || + "ws://localhost:3001", }); }, ); diff --git a/src/api/routes/policies/instance/domains.ts b/src/api/routes/policies/instance/domains.ts index 913e84dab..8e294401d 100644 --- a/src/api/routes/policies/instance/domains.ts +++ b/src/api/routes/policies/instance/domains.ts @@ -45,17 +45,25 @@ router.get( const IdentityForm = { cdn: + cdn.endpointPublic || + process.env.CDN || fs.readFileSync("./tmp/PROT", { encoding: "utf8" }) + "://" + fs.readFileSync("./tmp/HOST", { encoding: "utf8" }) || "http://localhost:3001", - gateway: websock || "ws://localhost:3001", + gateway: + gateway.endpointPublic || + process.env.GATEWAY || + websock || + "ws://localhost:3001", defaultApiVersion: api.defaultVersion ?? 9, apiEndpoint: + api.endpointPublic || fs.readFileSync("./tmp/PROT", { encoding: "utf8" }) + "://" + - fs.readFileSync("./tmp/HOST", { encoding: "utf8" }) || - "http://localhost:3001", + fs.readFileSync("./tmp/HOST", { encoding: "utf8" }) + + "/api" || + "http://localhost:3001/api", }; res.json(IdentityForm); diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts index 7040be757..74bbe823a 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts @@ -224,6 +224,7 @@ export async function postHandleMessage(message: Message) { // bit gross, but whatever! const endpointPublic = + Config.get().cdn.endpointPublic || fs.readFileSync("./tmp/PROT", { encoding: "utf8" }) + "://" + fs.readFileSync("./tmp/HOST", { encoding: "utf8" }) || diff --git a/src/cdn/routes/attachments.ts b/src/cdn/routes/attachments.ts index 05feda688..c4fa1a156 100644 --- a/src/cdn/routes/attachments.ts +++ b/src/cdn/routes/attachments.ts @@ -51,6 +51,7 @@ router.post( const path = `attachments/${channel_id}/${id}/${filename}`; const endpoint = + Config.get()?.cdn.endpointPublic || fs.readFileSync("./tmp/PROT", { encoding: "utf8" }) + "://" + fs.readFileSync("./tmp/HOST", { encoding: "utf8" }) || diff --git a/src/cdn/routes/avatars.ts b/src/cdn/routes/avatars.ts index 88c8eb21a..77635b260 100644 --- a/src/cdn/routes/avatars.ts +++ b/src/cdn/routes/avatars.ts @@ -64,6 +64,7 @@ router.post( const path = `avatars/${user_id}/${hash}`; const endpoint = + Config.get().cdn.endpointPublic || fs.readFileSync("./tmp/PROT", { encoding: "utf8" }) + "://" + fs.readFileSync("./tmp/HOST", { encoding: "utf8" }) || diff --git a/src/cdn/routes/guild-profiles.ts b/src/cdn/routes/guild-profiles.ts index 3b0a8d3ae..ba180e1df 100644 --- a/src/cdn/routes/guild-profiles.ts +++ b/src/cdn/routes/guild-profiles.ts @@ -61,6 +61,7 @@ router.post("/", multer.single("file"), async (req: Request, res: Response) => { const path = `guilds/${guild_id}/users/${user_id}/avatars/${hash}`; const endpoint = + Config.get().cdn.endpointPublic || fs.readFileSync("./tmp/PROT", { encoding: "utf8" }) + "://" + fs.readFileSync("./tmp/HOST", { encoding: "utf8" }) || diff --git a/src/cdn/routes/role-icons.ts b/src/cdn/routes/role-icons.ts index ae96f5583..50c3d573b 100644 --- a/src/cdn/routes/role-icons.ts +++ b/src/cdn/routes/role-icons.ts @@ -63,6 +63,7 @@ router.post( const path = `role-icons/${role_id}/${hash}.png`; const endpoint = + Config.get().cdn.endpointPublic || fs.readFileSync("./tmp/PROT", { encoding: "utf8" }) + "://" + fs.readFileSync("./tmp/HOST", { encoding: "utf8" }) || diff --git a/src/gateway/Server.ts b/src/gateway/Server.ts index d37b6b2e0..da3313dd8 100644 --- a/src/gateway/Server.ts +++ b/src/gateway/Server.ts @@ -78,7 +78,7 @@ export class Server { if (!this.server.listening) { this.server.listen(this.port); - console.log(`[Gateway] online on port ${this.port}`); + console.log(`[Gateway] online on 0.0.0.0:${this.port}`); } } diff --git a/src/util/connections/Connection.ts b/src/util/connections/Connection.ts index f35bb19e0..f226265f9 100644 --- a/src/util/connections/Connection.ts +++ b/src/util/connections/Connection.ts @@ -44,6 +44,7 @@ export abstract class Connection { */ getRedirectUri() { const endpointPublic = + Config.get().api.endpointPublic || fs.readFileSync("./tmp/PROT", { encoding: "utf8" }) + "://" + fs.readFileSync("./tmp/HOST", { encoding: "utf8" }) || diff --git a/src/util/util/cdn.ts b/src/util/util/cdn.ts index bd306a7c8..f9147af75 100644 --- a/src/util/util/cdn.ts +++ b/src/util/util/cdn.ts @@ -37,10 +37,12 @@ export async function uploadFile( }); const response = await fetch( - fs.readFileSync("./tmp/PROT", { encoding: "utf8" }) + - "://" + - fs.readFileSync("./tmp/HOST", { encoding: "utf8" }) + - path || "http://localhost:3001" + path, + Config.get().cdn.endpointPrivate + path || + fs.readFileSync("./tmp/PROT", { encoding: "utf8" }) + + "://" + + fs.readFileSync("./tmp/HOST", { encoding: "utf8" }) + + path || + "http://localhost:3001" + path, { headers: { diff --git a/src/util/util/email/index.ts b/src/util/util/email/index.ts index 307a6aa47..4dd4ba7c2 100644 --- a/src/util/util/email/index.ts +++ b/src/util/util/email/index.ts @@ -17,7 +17,7 @@ */ import fs from "fs"; -import fsp from "fs/promises"; +import fspromises from "fs/promises"; import path from "node:path"; import { SentMessageInfo, Transporter } from "nodemailer"; import { User } from "../../entities"; @@ -168,7 +168,7 @@ export const Email: { pwchange: "password_changed.html", }; - const template = await fsp.readFile( + const template = await fspromises.readFile( path.join( ASSET_FOLDER_PATH, "email_templates", diff --git a/src/webrtc/Server.ts b/src/webrtc/Server.ts index b9e2529f8..fa98eeac2 100644 --- a/src/webrtc/Server.ts +++ b/src/webrtc/Server.ts @@ -72,7 +72,7 @@ export class Server { await initEvent(); if (!this.server.listening) { this.server.listen(this.port); - console.log(`[WebRTC] online on port ${this.port}`); + console.log(`[WebRTC] online on 0.0.0.0:${this.port}`); } }