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 {
121121 if ( typeof jQuery === 'function' ) {
122122 this . registerjQueryAjaxSetup ( ) ;
123123 }
124+
125+ if ( typeof Turbo === 'object' ) {
126+ this . registerTurboRequestInterceptor ( ) ;
127+ }
124128 }
125129
126130 /**
@@ -161,6 +165,15 @@ export default class Echo {
161165 } ) ;
162166 }
163167 }
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+ }
164177}
165178
166179/**
Original file line number Diff line number Diff line change @@ -3,3 +3,4 @@ declare let io: any;
33declare let Vue : any ;
44declare let axios : any ;
55declare let jQuery : any ;
6+ declare let Turbo : any ;
You can’t perform that action at this time.
0 commit comments