@@ -12,7 +12,12 @@ import {
12
12
withIsolationScope ,
13
13
} from '@sentry/node' ;
14
14
import type { Client , Scope , Span , SpanAttributes } from '@sentry/types' ;
15
- import { addNonEnumerableProperty , objectify , stripUrlQueryAndFragment } from '@sentry/utils' ;
15
+ import {
16
+ addNonEnumerableProperty ,
17
+ objectify ,
18
+ stripUrlQueryAndFragment ,
19
+ winterCGRequestToRequestData ,
20
+ } from '@sentry/utils' ;
16
21
import type { APIContext , MiddlewareResponseHandler } from 'astro' ;
17
22
18
23
type MiddlewareOptions = {
@@ -86,11 +91,13 @@ async function instrumentRequest(
86
91
87
92
const isDynamicPageRequest = checkIsDynamicPageRequest ( ctx ) ;
88
93
94
+ const request = ctx . request ;
95
+
89
96
const { method, headers } = isDynamicPageRequest
90
- ? ctx . request
91
- : // headers can only be accessed in dynamic routes. Accessing `ctx. request.headers` in a static route
97
+ ? request
98
+ : // headers can only be accessed in dynamic routes. Accessing `request.headers` in a static route
92
99
// will make the server log a warning.
93
- { method : ctx . request . method , headers : undefined } ;
100
+ { method : request . method , headers : undefined } ;
94
101
95
102
return continueTrace (
96
103
{
@@ -101,7 +108,7 @@ async function instrumentRequest(
101
108
getCurrentScope ( ) . setSDKProcessingMetadata ( {
102
109
// We store the request on the current scope, not isolation scope,
103
110
// because we may have multiple requests nested inside each other
104
- request : isDynamicPageRequest ? ctx . request : { method, url : ctx . request . url } ,
111
+ request : isDynamicPageRequest ? winterCGRequestToRequestData ( request ) : { method, url : request . url } ,
105
112
} ) ;
106
113
107
114
if ( options . trackClientIp && isDynamicPageRequest ) {
0 commit comments