File tree Expand file tree Collapse file tree
linktreeclone-frontend/src/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import axios from 'axios' ;
22
33const apiClient = axios . create ( {
4- baseURL : 'https://linktree-clone-api-238899108893.southamerica-east1 .run.app' ,
4+ baseURL : 'https://linktree-clone-api-faw777jkuq-rj.a .run.app' ,
55} ) ;
66
77
@@ -15,4 +15,18 @@ apiClient.interceptors.request.use((config) => {
1515 return Promise . reject ( error ) ;
1616} ) ;
1717
18+ apiClient . interceptors . response . use (
19+ ( response ) => {
20+ return response ;
21+ } ,
22+ ( error ) => {
23+ if ( error . response && ( error . response . status === 401 || error . response . status === 403 ) ) {
24+ localStorage . removeItem ( 'authToken' ) ;
25+ window . location . href = '/login' ;
26+ console . log ( 'Sessão expirada. Redirecionando para o login.' ) ;
27+ }
28+ return Promise . reject ( error ) ;
29+ }
30+ ) ;
31+
1832export default apiClient ;
You can’t perform that action at this time.
0 commit comments