File tree 2 files changed +8
-4
lines changed 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -10,15 +10,16 @@ export const hardCodedCSRFCookie = (): string => {
10
10
// each document request. For local development, we don't use the Go webserver for static files,
11
11
// so this is the 'hack' to make local development work with remote apis.
12
12
// The CSRF cookie for this token is "JXm9hOUdZctWt0ZZGAy9xiS/gxMKYOThdxjjMnMUyn4="
13
- const csrfToken = "KNKvagCBEHZK7ihe2t7fj6VeJ0UyTDco1yVUJE8N06oNqxLu5Zx1vRxZbgfC0mJJgeGkVjgs08mgPbcWPBkZ1A=="
13
+ const csrfToken =
14
+ "KNKvagCBEHZK7ihe2t7fj6VeJ0UyTDco1yVUJE8N06oNqxLu5Zx1vRxZbgfC0mJJgeGkVjgs08mgPbcWPBkZ1A=="
14
15
axios . defaults . headers . common [ "X-CSRF-TOKEN" ] = csrfToken
15
16
return csrfToken
16
17
}
17
18
18
19
// Always attach CSRF token to all requests
19
20
const token = document . head . querySelector ( 'meta[property="csrf-token"]' )
20
21
if ( token !== null && token . getAttribute ( "content" ) !== null ) {
21
- if ( process . env . NODE_ENV === "development" ) {
22
+ if ( process . env . NODE_ENV === "development" ) {
22
23
// Development mode uses a hard-coded CSRF token
23
24
axios . defaults . headers . common [ "X-CSRF-TOKEN" ] = hardCodedCSRFCookie ( )
24
25
token . setAttribute ( "content" , hardCodedCSRFCookie ( ) )
@@ -27,7 +28,7 @@ if (token !== null && token.getAttribute("content") !== null) {
27
28
}
28
29
} else {
29
30
// Do not write error logs if we are in a FE unit test.
30
- if ( process . env . JEST_WORKER_ID === undefined ) {
31
+ if ( process . env . JEST_WORKER_ID === undefined ) {
31
32
console . error ( "CSRF token not found" )
32
33
}
33
34
}
Original file line number Diff line number Diff line change @@ -51,7 +51,10 @@ const config: Configuration = {
51
51
} ,
52
52
devMiddleware : {
53
53
publicPath : "/" ,
54
- headers : { "Set-Cookie" :"csrf_token=JXm9hOUdZctWt0ZZGAy9xiS/gxMKYOThdxjjMnMUyn4=; Path=/; HttpOnly; SameSite=Lax" }
54
+ headers : {
55
+ "Set-Cookie" :
56
+ "csrf_token=JXm9hOUdZctWt0ZZGAy9xiS/gxMKYOThdxjjMnMUyn4=; Path=/; HttpOnly; SameSite=Lax" ,
57
+ } ,
55
58
} ,
56
59
headers : {
57
60
"Access-Control-Allow-Origin" : "*" ,
You can’t perform that action at this time.
0 commit comments