File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -60,4 +60,35 @@ export const proxyMap: Record<string, Options> = {
60
60
}
61
61
} ,
62
62
} ,
63
+
64
+ "/kai" : {
65
+ target : KONVEYOR_ENV . TACKLE_HUB_URL || "http://localhost:9002" ,
66
+ logLevel : process . env . DEBUG ? "debug" : "info" ,
67
+
68
+ changeOrigin : true ,
69
+ pathRewrite : {
70
+ "^/kai" : "/services/kai" ,
71
+ } ,
72
+
73
+ onProxyReq : ( proxyReq , req , _res ) => {
74
+ // Add the Bearer token to the request if it is not already present, AND if
75
+ // the token is part of the request as a cookie
76
+ if ( req . cookies ?. keycloak_cookie && ! req . headers [ "authorization" ] ) {
77
+ proxyReq . setHeader (
78
+ "Authorization" ,
79
+ `Bearer ${ req . cookies . keycloak_cookie } `
80
+ ) ;
81
+ }
82
+ } ,
83
+ onProxyRes : ( proxyRes , req , res ) => {
84
+ const includesJsonHeaders =
85
+ req . headers . accept ?. includes ( "application/json" ) ;
86
+ if (
87
+ ( ! includesJsonHeaders && proxyRes . statusCode === 401 ) ||
88
+ ( ! includesJsonHeaders && proxyRes . statusMessage === "Unauthorized" )
89
+ ) {
90
+ res . redirect ( "/" ) ;
91
+ }
92
+ } ,
93
+ } ,
63
94
} ;
You can’t perform that action at this time.
0 commit comments