Skip to content

Commit 02ccd6c

Browse files
committed
cors: make hostname configurable via env variable
1 parent 75369a5 commit 02ccd6c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

β€Žcors-proxy/src/index.tsβ€Ž

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
const PORT = Bun.env.PORT || 3000;
7+
const HOST = Bun.env.HOST || "localhost";
78
const ALLOWED_ORIGINS = Bun.env.ALLOWED_ORIGINS?.split(",") || ["*"];
89
const MAX_REDIRECTS = 5;
910

@@ -114,6 +115,7 @@ async function proxyRequest(
114115
// Main server
115116
const server = Bun.serve({
116117
port: PORT,
118+
hostname: HOST,
117119
async fetch(req) {
118120
const url = new URL(req.url);
119121

@@ -222,6 +224,8 @@ const server = Bun.serve({
222224
},
223225
});
224226

225-
console.log(`πŸš€ CORS Proxy Server running on http://localhost:${server.port}`);
226-
console.log(`πŸ“‹ Health check: http://localhost:${server.port}/health`);
227+
console.log(
228+
`πŸš€ CORS Proxy Server running on http://${server.hostname}:${server.port}`
229+
);
230+
console.log(`πŸ“‹ Health check: http://${server.hostname}:${server.port}/health`);
227231
console.log(`🌍 Environment: ${Bun.env.NODE_ENV || "development"}`);

β€Žcors-proxy/tsconfig.jsonβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
// See also https://aka.ms/tsconfig/module
1010
"module": "nodenext",
1111
"target": "esnext",
12-
"types": [],
12+
"types": [
13+
"bun-types"
14+
],
1315
// For nodejs:
1416
// "lib": ["esnext"],
1517
// "types": ["node"],

0 commit comments

Comments
Β (0)