fix: use data.csrfToken
This commit is contained in:
@@ -88,9 +88,17 @@ const AuthProvider = ({ children }: AuthProviderProps) => {
|
|||||||
// csrf - include tokens in the axios header every time a request is made
|
// csrf - include tokens in the axios header every time a request is made
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getCsrfToken = async () => {
|
const getCsrfToken = async () => {
|
||||||
const { data } = await axios.get('http://localhost:8080/csrf-token');
|
try {
|
||||||
console.log('CSRFFFFF =>>>>', data);
|
const { data } = await axios.get('http://localhost:8080/csrf-token');
|
||||||
(axios.defaults.headers as any)['X-CSRF-TOKEN'] = data.getCsrfToken;
|
console.log('CSRF Token Response:', data);
|
||||||
|
if (data && data.csrfToken) {
|
||||||
|
(axios.defaults.headers as any)['X-CSRF-TOKEN'] = data.csrfToken;
|
||||||
|
} else {
|
||||||
|
console.error('CSRF token not found in the response');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching CSRF token:', error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
getCsrfToken();
|
getCsrfToken();
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user