remove "the backend server is reachable"
This commit is contained in:
1 parent
791714caeb
commit
8e495d1251
1 file changed
+1
-33
@@ -513,39 +513,7 @@ class NetworkService {
|
|||||||
return this.axiosInstance.get("/auth/users/superadmin");
|
return this.axiosInstance.get("/auth/users/superadmin");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* ************************************
|
|
||||||
* Checks if the backend server is reachable
|
|
||||||
* ************************************
|
|
||||||
*
|
|
||||||
* @async
|
|
||||||
* @returns {Promise<boolean>} True if backend is reachable, false otherwise
|
|
||||||
*/
|
|
||||||
async checkBackendReachability() {
|
|
||||||
try {
|
|
||||||
// Create a temporary instance that doesn't follow redirects and has a short timeout
|
|
||||||
const tempInstance = axios.create({
|
|
||||||
maxRedirects: 0,
|
|
||||||
baseURL: this.axiosInstance.defaults.baseURL,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Make a simple GET request to the root endpoint
|
|
||||||
await tempInstance.get('/', {
|
|
||||||
headers: {
|
|
||||||
Authorization: undefined // Prevent sending the auth token
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (error) {
|
|
||||||
// If we get a successful HTTP status or redirect, the backend is reachable
|
|
||||||
if (error.response) {
|
|
||||||
return true; // Server responded with any status code, so it's reachable
|
|
||||||
}
|
|
||||||
console.error("Backend connection failed:", error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ************************************
|
* ************************************
|
||||||
|
|||||||
Reference in new issue
Block a user