mirror of
https://github.com/streetwriters/notesnook-sync-server.git
synced 2026-02-12 11:12:44 +00:00
cors: make hostname configurable via env variable
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
const PORT = Bun.env.PORT || 3000;
|
||||
const HOST = Bun.env.HOST || "localhost";
|
||||
const ALLOWED_ORIGINS = Bun.env.ALLOWED_ORIGINS?.split(",") || ["*"];
|
||||
const MAX_REDIRECTS = 5;
|
||||
|
||||
@@ -114,6 +115,7 @@ async function proxyRequest(
|
||||
// Main server
|
||||
const server = Bun.serve({
|
||||
port: PORT,
|
||||
hostname: HOST,
|
||||
async fetch(req) {
|
||||
const url = new URL(req.url);
|
||||
|
||||
@@ -222,6 +224,8 @@ const server = Bun.serve({
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`🚀 CORS Proxy Server running on http://localhost:${server.port}`);
|
||||
console.log(`📋 Health check: http://localhost:${server.port}/health`);
|
||||
console.log(
|
||||
`🚀 CORS Proxy Server running on http://${server.hostname}:${server.port}`
|
||||
);
|
||||
console.log(`📋 Health check: http://${server.hostname}:${server.port}/health`);
|
||||
console.log(`🌍 Environment: ${Bun.env.NODE_ENV || "development"}`);
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
// See also https://aka.ms/tsconfig/module
|
||||
"module": "nodenext",
|
||||
"target": "esnext",
|
||||
"types": [],
|
||||
"types": [
|
||||
"bun-types"
|
||||
],
|
||||
// For nodejs:
|
||||
// "lib": ["esnext"],
|
||||
// "types": ["node"],
|
||||
|
||||
Reference in New Issue
Block a user