File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -297,11 +297,15 @@ export function useConnection({
297
297
bearerToken || ( await serverAuthProvider . tokens ( ) ) ?. access_token ;
298
298
if ( token ) {
299
299
const authHeaderName = headerName || "Authorization" ;
300
- headers [ authHeaderName ] = token ;
301
300
302
301
// Add custom header name as a special request header to let the server know which header to pass through
303
- if ( headerName && headerName . toLowerCase ( ) !== "authorization" ) {
304
- headers [ "x-custom-auth-header" ] = headerName ;
302
+ if ( authHeaderName . toLowerCase ( ) !== "authorization" ) {
303
+ headers [ authHeaderName ] = token ;
304
+ if ( headerName ) {
305
+ headers [ "x-custom-auth-header" ] = headerName ;
306
+ }
307
+ } else {
308
+ headers [ authHeaderName ] = `Bearer ${ token } ` ;
305
309
}
306
310
}
307
311
Original file line number Diff line number Diff line change @@ -95,9 +95,9 @@ const createTransport = async (req: express.Request): Promise<Transport> => {
95
95
// If the header "x-custom-auth-header" is present, use its value as the custom header name.
96
96
if ( req . headers [ "x-custom-auth-header" ] !== undefined ) {
97
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 ;
98
+ if ( req . headers [ customHeaderName ] !== undefined ) {
99
+ const value = req . headers [ customHeaderName ] ;
100
+ headers [ customHeaderName ] = value as string ;
101
101
}
102
102
}
103
103
@@ -132,9 +132,9 @@ const createTransport = async (req: express.Request): Promise<Transport> => {
132
132
// If the header "x-custom-auth-header" is present, use its value as the custom header name.
133
133
if ( req . headers [ "x - custom - auth - header "] !== undefined ) {
134
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 ;
135
+ if ( req . headers [ customHeaderName ] !== undefined ) {
136
+ const value = req . headers [ customHeaderName ] ;
137
+ headers [ customHeaderName ] = value as string ;
138
138
}
139
139
}
140
140
You can’t perform that action at this time.
0 commit comments