From 1ea610fcdebd3915ec07f2181c81027d2d3f15d3 Mon Sep 17 00:00:00 2001 From: Daven Quinn Date: Sat, 13 Jul 2024 03:39:22 -0400 Subject: [PATCH] Fixed url path components --- server/index.ts | 27 +++++++++++++++------------ src/pages/+config.ts | 1 + 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/server/index.ts b/server/index.ts index f963b13f..545cac2f 100644 --- a/server/index.ts +++ b/server/index.ts @@ -96,21 +96,24 @@ async function startServer() { process.env.VITE_MACROSTRAT_INSTANCE ); - // + // CriticalMAAS CDR integration // Proxy requests to /tile/* to https://api.cdr.land/v1/tiles/* // Add the Authorization header to the proxied request // - app.use("/tiles", proxy( - "https://api.cdr.land", { - proxyReqOptDecorator: (opts) => { - opts.headers["Authorization"] = `Bearer ${process.env.CDR_API_KEY}`; - return opts; - }, - proxyReqPathResolver: (req) => { - return `/v1/tiles${req.url}`; - } - }) - ) + if (process.env.CDR_API_KEY) { + app.use( + "/tiles", + proxy("https://api.cdr.land", { + proxyReqOptDecorator: (opts) => { + opts.headers["Authorization"] = `Bearer ${process.env.CDR_API_KEY}`; + return opts; + }, + proxyReqPathResolver: (req) => { + return `/v1/tiles${req.url}`; + }, + }) + ); + } /** * Vike route diff --git a/src/pages/+config.ts b/src/pages/+config.ts index a748656b..475e646e 100644 --- a/src/pages/+config.ts +++ b/src/pages/+config.ts @@ -25,6 +25,7 @@ export default { "description", "title", "environment", + "urlPathname", ], clientRouting: true, meta: {