File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
drupal/web/themes/react_example_theme/js/src/utils Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 11
11
* Options to pass to fetch for the call to fetchUrl.
12
12
*/
13
13
export const fetchWithCSRFToken = ( csrfUrl , fetchUrl , fetchOptions ) => {
14
+
14
15
if ( ! fetchOptions . headers . get ( 'X-CSRF-Token' ) ) {
15
- return fetch ( csrfUrl )
16
+ return fetch ( ` ${ drupalSettings . path . baseUrl } ${ csrfUrl } ` )
16
17
. then ( response => response . text ( ) )
17
18
. then ( ( csrfToken ) => {
18
19
fetchOptions . headers . append ( 'X-CSRF-Token' , csrfToken ) ;
19
- return fetch ( fetchUrl , fetchOptions ) ;
20
+ return fetch ( ` ${ drupalSettings . path . baseUrl } ${ fetchUrl } ` , fetchOptions ) ;
20
21
} ) ;
21
22
}
22
23
else {
23
- return fetch ( fetchUrl , fetchOptions ) ;
24
+ return fetch ( ` ${ drupalSettings . path . baseUrl } ${ fetchUrl } ` , fetchOptions ) ;
24
25
}
25
26
} ;
You can’t perform that action at this time.
0 commit comments