File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,16 +136,18 @@ function instrumentFetch(onFetchResolved?: (response: Response) => void): void {
136136 error . message === 'NetworkError when attempting to fetch resource.' )
137137 ) {
138138 try {
139- const url = new URL ( handlerData . fetchData . url ) ;
139+ const url = new URL ( handlerData . fetchData . url , GLOBAL_OBJ . location ?. origin ) ;
140140 const hostname = url . host ;
141141
142- if ( enhanceOption === 'always' ) {
143- // Modify the error message directly
144- error . message = `${ error . message } (${ hostname } )` ;
145- } else {
146- // Store hostname as non-enumerable property for Sentry-only enhancement
147- // This preserves the original error message for third-party packages
148- addNonEnumerableProperty ( error , '__sentry_fetch_url_host__' , hostname ) ;
142+ if ( hostname ) {
143+ if ( enhanceOption === 'always' ) {
144+ // Modify the error message directly
145+ error . message = `${ error . message } (${ hostname } )` ;
146+ } else {
147+ // Store hostname as non-enumerable property for Sentry-only enhancement
148+ // This preserves the original error message for third-party packages
149+ addNonEnumerableProperty ( error , '__sentry_fetch_url_host__' , hostname ) ;
150+ }
149151 }
150152 } catch {
151153 // ignore it if errors happen here
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import type { SdkSource } from './env';
1919/** Internal global with common properties and Sentry extensions */
2020export type InternalGlobal = {
2121 navigator ?: { userAgent ?: string ; maxTouchPoints ?: number } ;
22+ location ?: { origin ?: string } ;
2223 console : Console ;
2324 PerformanceObserver ?: any ;
2425 Sentry ?: any ;
You can’t perform that action at this time.
0 commit comments