Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface Config {
ENDPOINT: string;
BUCKET_NAME: string;
REGION: string;
CDN_URL: string;
};
CLOUDFLARE: {
CDN_DOMAIN: string;
Expand Down Expand Up @@ -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!,
Expand Down
2 changes: 1 addition & 1 deletion src/config/s3.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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}`);
3 changes: 2 additions & 1 deletion src/utils/cors-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down