1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-11 03:34:35 +00:00

fix(cookie): XSRF cookie is removed and passed token in head section

This commit is contained in:
Saad Jutt
2022-08-03 03:38:11 +05:00
parent 78bea7c154
commit 77f8d30baf
3 changed files with 22 additions and 6 deletions

View File

@@ -80,7 +80,18 @@ const AppContextProvider = (props: { children: ReactNode }) => {
})
.catch(() => {
setLoggedIn(false)
axios.get('/') // get CSRF TOKEN
// get CSRF TOKEN and set cookie
axios
.get('/')
.then((res) => res.data)
.then((data: string) => {
const result =
/<script>document.cookie = '(XSRF-TOKEN=[A-Za-z-0-9; =/]*)'<\/script>/.exec(
data
)?.[1]
if (result) document.cookie = result
})
})
axios