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