File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,27 @@ module.exports = {
77 } ,
88 ] ,
99 beforeRequestHandler : [
10+ {
11+ path : "/sap" ,
12+ handler : function sapClientMiddleware ( req , res , next ) {
13+ if ( req . user && req . user . scopes && Array . isArray ( req . user . scopes ) ) {
14+ const scopePrefix = "HTML5UserAPIforCF!t5585.Client" ;
15+ const matchingScope = req . user . scopes . find (
16+ ( scope ) =>
17+ typeof scope === "string" && scope . startsWith ( scopePrefix )
18+ ) ;
19+
20+ if ( matchingScope ) {
21+ const clientNumber = matchingScope . substring ( scopePrefix . length ) ;
22+ if ( clientNumber ) {
23+ req . headers [ "sap-client" ] = clientNumber ;
24+ console . log ( "Set sap-client header to: %s" , clientNumber ) ;
25+ }
26+ }
27+ }
28+ return next ( ) ;
29+ } ,
30+ } ,
1031 {
1132 path : "/services/userapi/currentUser" ,
1233 handler : function myMiddleware ( req , res , next ) {
You can’t perform that action at this time.
0 commit comments