This commit is contained in:
2022-05-27 14:39:05 +03:00
parent f7367dbdf2
commit e9e3880ad3
26 changed files with 718 additions and 33 deletions

View File

@ -8,7 +8,7 @@ export const withAuthRedirect =
.then((res) => {
if (res.status && res.status == 401) {
localStorage.clear()
logout()
logout && logout()
history.push(role === 'ROLE_DEV' ? '/authdev' : '/auth')
}
@ -16,7 +16,7 @@ export const withAuthRedirect =
})
.catch((err) => {
localStorage.clear()
logout()
logout && logout()
history.push(role === 'ROLE_DEV' ? '/authdev' : '/auth')
})
}

View File

@ -49,6 +49,7 @@ export const fetchAuth = async ({
response.json().then((resJSON) => {
localStorage.setItem('auth_token', resJSON.access_token)
localStorage.setItem('id', resJSON.id)
localStorage.setItem(
'access_token_expired_at',
resJSON.access_token_expired_at
@ -104,7 +105,8 @@ export const fetchPost = withAuthRedirect(async (link, body) => {
headers: {
Authorization: `Bearer ${localStorage.getItem('auth_token')}`,
'Content-Type': 'application/json',
Origin: `http://localhost`
//Origin: `http://localhost:3000`
Origin: `${process.env.REACT_APP_BASE_URL}`,
},
body: JSON.stringify(body)
})