Skip to content

Commit

Permalink
fix: rever http-proxy-middleware version and make sure the container …
Browse files Browse the repository at this point in the history
…works with it
  • Loading branch information
carlosthe19916 committed Oct 11, 2024
1 parent bf8934a commit 52ee5d3
Show file tree
Hide file tree
Showing 5 changed files with 1,190 additions and 4,072 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const ImporterForm: React.FC<IImporterFormProps> = ({
periodValue: periodValue || 60,
periodUnit: periodUnit || "s",
v3Signatures: importerConfiguration?.v3Signatures ?? false,
enabled: !importerConfiguration?.disabled ?? true,
enabled: importerConfiguration?.disabled ?? true,
keys: importerConfiguration?.keys?.map((e) => ({ value: e })) ?? [],
onlyPatterns:
importerConfiguration?.onlyPatterns?.map((e) => ({ value: e })) ?? [],
Expand Down
2 changes: 1 addition & 1 deletion common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
},
"dependencies": {
"ejs": "^3.1.10",
"http-proxy-middleware": "^3.0.0"
"http-proxy-middleware": "^2.0.6"
}
}
42 changes: 20 additions & 22 deletions common/src/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,27 @@ import { TRUSTIFICATION_ENV } from "./environment.js";
export const proxyMap: Record<string, Options> = {
"/api": {
target: TRUSTIFICATION_ENV.TRUSTIFY_API_URL || "http://localhost:8080",
logger: process.env.DEBUG ? "debug" : "info",
logLevel: process.env.DEBUG ? "debug" : "info",
changeOrigin: true,
on: {
proxyReq: (proxyReq: any, req: any, _res: any) => {
// 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}`
);
}
},
proxyRes: (proxyRes: any, req: any, res: any) => {
const includesJsonHeaders =
req.headers.accept?.includes("application/json");
if (
(!includesJsonHeaders && proxyRes.statusCode === 401) ||
(!includesJsonHeaders && proxyRes.statusMessage === "Unauthorized")
) {
res.redirect("/");
}
},
onProxyReq: (proxyReq: any, req: any, _res: any) => {
// 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}`
);
}
},
onProxyReq: (proxyRes: any, req: any, res: any) => {
const includesJsonHeaders =
req.headers.accept?.includes("application/json");
if (
(!includesJsonHeaders && proxyRes.statusCode === 401) ||
(!includesJsonHeaders && proxyRes.statusMessage === "Unauthorized")
) {
res.redirect("/");
}
},
},
};
Loading

0 comments on commit 52ee5d3

Please sign in to comment.