File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,10 @@ export default class Echo {
121
121
if ( typeof jQuery === 'function' ) {
122
122
this . registerjQueryAjaxSetup ( ) ;
123
123
}
124
+
125
+ if ( typeof Turbo === 'object' ) {
126
+ this . registerTurboRequestInterceptor ( ) ;
127
+ }
124
128
}
125
129
126
130
/**
@@ -161,6 +165,15 @@ export default class Echo {
161
165
} ) ;
162
166
}
163
167
}
168
+
169
+ /**
170
+ * Register the Turbo Request interceptor to add the X-Socket-ID header.
171
+ */
172
+ registerTurboRequestInterceptor ( ) : void {
173
+ document . addEventListener ( 'turbo:before-fetch-request' , ( event : any ) => {
174
+ event . detail . fetchOptions . headers [ 'X-Socket-Id' ] = this . socketId ( ) ;
175
+ } ) ;
176
+ }
164
177
}
165
178
166
179
/**
Original file line number Diff line number Diff line change @@ -3,3 +3,4 @@ declare let io: any;
3
3
declare let Vue : any ;
4
4
declare let axios : any ;
5
5
declare let jQuery : any ;
6
+ declare let Turbo : any ;
You can’t perform that action at this time.
0 commit comments