Skip to content

Commit

Permalink
Fixed url path components
Browse files Browse the repository at this point in the history
  • Loading branch information
davenquinn committed Jul 13, 2024
1 parent 5bc42ad commit 1ea610f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
27 changes: 15 additions & 12 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/pages/+config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default {
"description",
"title",
"environment",
"urlPathname",
],
clientRouting: true,
meta: {
Expand Down

0 comments on commit 1ea610f

Please sign in to comment.