Skip to content

Commit

Permalink
chore(cors): check cors errors in api client
Browse files Browse the repository at this point in the history
  • Loading branch information
anteqkois committed Jun 9, 2024
1 parent 1b427ec commit 2a09bcd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions apps/web/libs/api-client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AuthStatus, Cookies } from '@linkerry/shared'
import axios from 'axios'
// import { useRouter } from 'next/router';
// import { store } from '../../features/common/store';
Expand Down Expand Up @@ -33,12 +32,17 @@ apiClient.interceptors.response.use(
const originalRequest = error.config

if (!error.response) {
console.log('API CLIENT ERROR')
console.log(error)
console.log(error.message)
console.log(error?.response)
console.dir(error, { depth: null })
// Network error or CORS error
if (error.message === 'Network Error' || error.message.includes('CORS')) {
console.error('CORS error detected:', error.message)
window.location.href = '/cors-error'
return Promise.reject(error)
}
// if (error.message === 'Network Error' || error.message.includes('CORS')) {
// console.error('CORS error detected:', error.message)
// window.location.href = '/cors-error'
// return Promise.reject(error)
// }
}

if (error?.response?.status == 401 && error?.config && !error?.config?._isRetry) {
Expand Down

0 comments on commit 2a09bcd

Please sign in to comment.