@@ -96,6 +96,8 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
9696 private maxReconnectAttempts : number ;
9797 private reconnectDelay : number ;
9898 private reconnectAttempts : number = 0 ;
99+ private baseUrl : string ;
100+ private token ?: string ;
99101
100102 constructor ( config : {
101103 baseUrl : string ;
@@ -114,6 +116,8 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
114116 this . autoReconnect = config . autoReconnect ?? true ;
115117 this . maxReconnectAttempts = config . maxReconnectAttempts ?? 3 ;
116118 this . reconnectDelay = config . reconnectDelay ?? 1000 ;
119+ this . baseUrl = config . baseUrl ;
120+ this . token = config . token ;
117121 }
118122
119123 /**
@@ -720,8 +724,7 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
720724 formData . append ( 'metadata' , JSON . stringify ( options . metadata ) ) ;
721725 }
722726
723- const baseUrl = ( this . client as any ) . baseUrl || '' ;
724- const url = `${ baseUrl } /api/data/${ encodeURIComponent ( resource ) } /upload` ;
727+ const url = `${ this . baseUrl } /api/data/${ encodeURIComponent ( resource ) } /upload` ;
725728
726729 const response = await fetch ( url , {
727730 method : 'POST' ,
@@ -779,8 +782,7 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
779782 formData . append ( 'metadata' , JSON . stringify ( options . metadata ) ) ;
780783 }
781784
782- const baseUrl = ( this . client as any ) . baseUrl || '' ;
783- const url = `${ baseUrl } /api/data/${ encodeURIComponent ( resource ) } /upload` ;
785+ const url = `${ this . baseUrl } /api/data/${ encodeURIComponent ( resource ) } /upload` ;
784786
785787 const response = await fetch ( url , {
786788 method : 'POST' ,
@@ -803,14 +805,12 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
803805 }
804806
805807 /**
806- * Get authorization headers from the underlying client (if any) .
808+ * Get authorization headers from the adapter config .
807809 */
808810 private getAuthHeaders ( ) : Record < string , string > {
809811 const headers : Record < string , string > = { } ;
810- // Access token from client config if available
811- const token = ( this . client as any ) . token || ( this . client as any ) . config ?. token ;
812- if ( token ) {
813- headers [ 'Authorization' ] = `Bearer ${ token } ` ;
812+ if ( this . token ) {
813+ headers [ 'Authorization' ] = `Bearer ${ this . token } ` ;
814814 }
815815 return headers ;
816816 }
0 commit comments