Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Sep 11, 2024
1 parent de4608e commit c81788d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions common/src/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,35 @@ export const proxyMap: Record<string, Options> = {
}
},
},

"/kai": {
target: KONVEYOR_ENV.TACKLE_HUB_URL || "http://localhost:9002",
logLevel: process.env.DEBUG ? "debug" : "info",

changeOrigin: true,
pathRewrite: {
"^/kai": "/services/kai",
},

onProxyReq: (proxyReq, req, _res) => {
// Add the Bearer token to the request if it is not already present, AND if
// the token is part of the request as a cookie
if (req.cookies?.keycloak_cookie && !req.headers["authorization"]) {
proxyReq.setHeader(
"Authorization",
`Bearer ${req.cookies.keycloak_cookie}`
);
}
},
onProxyRes: (proxyRes, req, res) => {
const includesJsonHeaders =
req.headers.accept?.includes("application/json");
if (
(!includesJsonHeaders && proxyRes.statusCode === 401) ||
(!includesJsonHeaders && proxyRes.statusMessage === "Unauthorized")
) {
res.redirect("/");
}
},
},
};

0 comments on commit c81788d

Please sign in to comment.