@@ -91,6 +91,15 @@ const createTransport = async (req: express.Request): Promise<Transport> => {
91
91
const value = req . headers [ key ] ;
92
92
headers [ key ] = Array . isArray ( value ) ? value [ value . length - 1 ] : value ;
93
93
}
94
+
95
+ // If the header "x-custom-auth-header" is present, use its value as the custom header name.
96
+ if ( req . headers [ "x-custom-auth-header" ] !== undefined ) {
97
+ const customHeaderName = req . headers [ "x-custom-auth-header" ] as string ;
98
+ if ( req . headers [ customHeaderName . toLowerCase ( ) ] !== undefined ) {
99
+ const value = req . headers [ customHeaderName . toLowerCase ( ) ] ;
100
+ headers [ customHeaderName ] = Array . isArray ( value ) ? value [ value . length - 1 ] : value as string ;
101
+ }
102
+ }
94
103
95
104
console . log ( `SSE transport: url=${ url } , headers=${ Object . keys ( headers ) } ` ) ;
96
105
@@ -119,6 +128,15 @@ const createTransport = async (req: express.Request): Promise<Transport> => {
119
128
const value = req . headers [ key ] ;
120
129
headers [ key ] = Array . isArray ( value ) ? value [ value . length - 1 ] : value ;
121
130
}
131
+
132
+ // If the header "x-custom-auth-header" is present, use its value as the custom header name.
133
+ if ( req . headers [ "x-custom-auth-header" ] !== undefined ) {
134
+ const customHeaderName = req . headers [ "x-custom-auth-header" ] as string ;
135
+ if ( req . headers [ customHeaderName . toLowerCase ( ) ] !== undefined ) {
136
+ const value = req . headers [ customHeaderName . toLowerCase ( ) ] ;
137
+ headers [ customHeaderName ] = Array . isArray ( value ) ? value [ value . length - 1 ] : value as string ;
138
+ }
139
+ }
122
140
123
141
const transport = new StreamableHTTPClientTransport (
124
142
new URL ( query . url as string ) ,
0 commit comments