feat: add localhost to cors

This commit is contained in:
Julien Calixte
2026-01-11 23:00:47 +01:00
parent b5a5b973f7
commit a2cd9693a3

View File

@@ -5,7 +5,7 @@ const DEEPL_API_KEY = Deno.env.get("DEEPL_AUTH_KEY");
const BEARER_TOKEN = Deno.env.get("BEARER_TOKEN");
const PORT = parseInt(Deno.env.get("PORT") || "8000");
const DEEPL_API_BASE = "https://api-free.deepl.com/v2";
const FRONTEND_URL = "https://deep-lite.netlify.app";
const FRONTEND_URLS = ["http://localhost", "https://deep-lite.netlify.app"];
if (!DEEPL_API_KEY) {
console.error("ERROR: DEEPL_AUTH_KEY environment variable is required");
@@ -23,7 +23,7 @@ const router = new Router();
// CORS middleware - only allow requests from the PWA frontend
app.use(
oakCors({
origin: FRONTEND_URL,
origin: FRONTEND_URLS,
credentials: true,
}),
);
@@ -135,7 +135,7 @@ app.use(router.routes());
app.use(router.allowedMethods());
console.log(`🚀 DeepLite BFF server running on http://localhost:${PORT}`);
console.log(`📝 CORS enabled for: ${FRONTEND_URL}`);
console.log(`📝 CORS enabled for: ${FRONTEND_URLS}`);
console.log(`🔒 Bearer token authentication enabled`);
await app.listen({ port: PORT });