feat: add localhost to cors
This commit is contained in:
@@ -5,7 +5,7 @@ const DEEPL_API_KEY = Deno.env.get("DEEPL_AUTH_KEY");
|
|||||||
const BEARER_TOKEN = Deno.env.get("BEARER_TOKEN");
|
const BEARER_TOKEN = Deno.env.get("BEARER_TOKEN");
|
||||||
const PORT = parseInt(Deno.env.get("PORT") || "8000");
|
const PORT = parseInt(Deno.env.get("PORT") || "8000");
|
||||||
const DEEPL_API_BASE = "https://api-free.deepl.com/v2";
|
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) {
|
if (!DEEPL_API_KEY) {
|
||||||
console.error("ERROR: DEEPL_AUTH_KEY environment variable is required");
|
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
|
// CORS middleware - only allow requests from the PWA frontend
|
||||||
app.use(
|
app.use(
|
||||||
oakCors({
|
oakCors({
|
||||||
origin: FRONTEND_URL,
|
origin: FRONTEND_URLS,
|
||||||
credentials: true,
|
credentials: true,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@@ -135,7 +135,7 @@ app.use(router.routes());
|
|||||||
app.use(router.allowedMethods());
|
app.use(router.allowedMethods());
|
||||||
|
|
||||||
console.log(`🚀 DeepLite BFF server running on http://localhost:${PORT}`);
|
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`);
|
console.log(`🔒 Bearer token authentication enabled`);
|
||||||
|
|
||||||
await app.listen({ port: PORT });
|
await app.listen({ port: PORT });
|
||||||
|
|||||||
Reference in New Issue
Block a user