Skip to content

Modern Docker Management, Designed for Everyone

fix: auth redirect (i hope)

Kyle Mendell92c1685c238e
diff --git a/backend/internal/middleware/auth_middleware.go b/backend/internal/middleware/auth_middleware.go
index 36724fca0..ef2920ba6 100644
--- a/backend/internal/middleware/auth_middleware.go
+++ b/backend/internal/middleware/auth_middleware.go
@@ -40,8 +40,9 @@ func AuthMiddleware(authService *services.AuthService) gin.HandlerFunc {
return
}
- // Store userID instead of full user object
+ // Store both userID and full user for handlers that expect currentUser
c.Set("userID", user.ID)
+ c.Set("currentUser", user)
c.Next()
}
diff --git a/frontend/src/lib/services/api/api-service.ts b/frontend/src/lib/services/api/api-service.ts
index 57bc7ea9c..4dc2c7129 100644
--- a/frontend/src/lib/services/api/api-service.ts
+++ b/frontend/src/lib/services/api/api-service.ts
@@ -14,14 +14,38 @@ abstract class BaseAPIService {
this.api.interceptors.response.use(
(response) => response,
(error) => {
+ console.log(error);
const status = error?.response?.status;
if (status === 401 && typeof window !== 'undefined') {
- const reqUrl: string = error?.config?.url ?? '';
- // Skip auth endpoints and public endpoints to avoid loops
- const isAuthApi =
- reqUrl.startsWith('/auth') ||
- reqUrl.startsWith('/oidc') ||
- reqUrl.startsWith('/settings/public');
+ let reqUrl: string = error?.config?.url ?? '';
+ const baseURL: string = error?.config?.baseURL ?? this.api.defaults.baseURL ?? '';
+ try {
+ if (/^https?:\/\//i.test(reqUrl)) {
+ const u = new URL(reqUrl);
+ reqUrl = u.pathname;
+ } else if (baseURL && /^https?:\/\//i.test(baseURL)) {
+ // if baseURL is absolute and url is relative, construct full url then extract pathname
+ const u = new URL(reqUrl, baseURL);
+ reqUrl = u.pathname;
+ }
+ } catch (e) {
+ // ignore URL parse errors and fall back to raw reqUrl
+ }
+
+ if (reqUrl.startsWith('/api')) {
+ reqUrl = reqUrl.slice(4) || '/';
+ }
+
+ const skipAuthPaths = [
+ '/auth/login',
+ '/auth/logout',
+ '/auth/oidc',
+ '/auth/oidc/login',
+ '/auth/oidc/callback',
+ '/settings/public'
+ ];
+ const isAuthApi = skipAuthPaths.some((p) => reqUrl.startsWith(p));
+
const pathname = window.location.pathname || '/';
const isOnAuthPage = pathname.startsWith('/auth');