express-sweet-generator 2.0.19 → 2.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -41,9 +41,17 @@ export default class extends components.Api {
|
|
|
41
41
|
errorHook(code, error) {
|
|
42
42
|
// Check if the error object and request properties exist to avoid runtime errors
|
|
43
43
|
if (error && error.request && error.request.responseURL) {
|
|
44
|
+
// Log the error details.
|
|
45
|
+
console.error(`API Error: Code ${code}, Message: ${error.message}, URL: ${error.request.responseURL}`);
|
|
46
|
+
|
|
47
|
+
// Get the pathname from the request URL.
|
|
44
48
|
const {pathname} = new URL(error.request.responseURL);
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
|
|
50
|
+
// Define paths that should be excluded from the redirect.
|
|
51
|
+
const excludedPaths = ['/api/users/login'];
|
|
52
|
+
|
|
53
|
+
// Redirect to the login page if an authentication error occurs on a non-login request.
|
|
54
|
+
if (!excludedPaths.includes(pathname) && code === 401) {
|
|
47
55
|
location.replace('/');
|
|
48
56
|
}
|
|
49
57
|
}
|
|
@@ -96,8 +96,11 @@ export default class extends components.Datatable {
|
|
|
96
96
|
* @return {void}
|
|
97
97
|
*/
|
|
98
98
|
ajaxErrorHook(code) {
|
|
99
|
+
// Log the error details.
|
|
100
|
+
console.error(`DataTable AJAX error: Status code ${code}`);
|
|
101
|
+
|
|
102
|
+
// Redirect to login page if authentication error occurs.
|
|
99
103
|
if (code === 401) {
|
|
100
|
-
// Redirect to login page if authentication error occurs.
|
|
101
104
|
location.replace('/');
|
|
102
105
|
}
|
|
103
106
|
}
|