diff --git a/src/config/config.ts b/src/config/config.ts index 33ace71..a9f59f0 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -38,6 +38,7 @@ interface Config { ENDPOINT: string; BUCKET_NAME: string; REGION: string; + CDN_URL: string; }; CLOUDFLARE: { CDN_DOMAIN: string; @@ -78,6 +79,7 @@ const config: Config = { ENDPOINT: process.env.S3_ENDPOINT!, BUCKET_NAME: process.env.S3_BUCKET_NAME!, REGION: process.env.S3_REGION!, + CDN_URL: process.env.S3_CDN_URL!, }, CLOUDFLARE: { CDN_DOMAIN: process.env.CLOUDFLARE_CDN_DOMAIN!, diff --git a/src/config/s3.config.ts b/src/config/s3.config.ts index 57e2e9b..f5dd3cb 100644 --- a/src/config/s3.config.ts +++ b/src/config/s3.config.ts @@ -53,7 +53,7 @@ export class S3Service { } public buildCDNUrl(key: string): string { - return `https://fileflow.fsn1.your-objectstorage.com/${key}`; + return `${config.S3.CDN_URL}/${key}`; } /** diff --git a/src/index.ts b/src/index.ts index bc0d0d9..b800d7b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,10 +6,12 @@ import config from "@/config/config"; const app = new App(); const socketEngine = app.getSocketEngine(); const port = config.PORT || 3000; +const hostname = "0.0.0.0"; // Use IP from env or default to 0.0.0.0 (all interfaces) // Start Bun server Bun.serve({ port, + // hostname, idleTimeout: 30, websocket: socketEngine.handler().websocket, // <-- attach WebSocket handler async fetch(req, server) { @@ -36,4 +38,6 @@ Bun.serve({ : {}), }); -console.log(`🚀 Server running on http${config.HTTP2.SSL.ENABLED ? "s" : ""}://localhost:${port}`); +const protocol = config.HTTP2.SSL.ENABLED ? "https" : "http"; +const displayHost = hostname === "0.0.0.0" ? "localhost" : hostname; +console.log(`🚀 Server running on ${protocol}://${displayHost}:${port}`); diff --git a/src/utils/cors-options.ts b/src/utils/cors-options.ts index 594abbf..29a31ab 100644 --- a/src/utils/cors-options.ts +++ b/src/utils/cors-options.ts @@ -8,7 +8,8 @@ export const corsOptions = { "http://localhost:3001", "http://localhost:5000", "http://localhost:5173", - "https://fileflow.nerchuko.in" + "https://fileflow.nerchuko.in", + "http://192.168.0.8:5173", ], credentials: true, exposedHeaders: ["sessionid", "logintoken", "resettoken", "ratelimit-remaining"],