mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-30 21:59:46 +02:00
Merge pull request #634 from AnishSarkar22/fix/docker
Fixed docker login issue
This commit is contained in:
commit
dc0789edba
1 changed files with 11 additions and 9 deletions
|
|
@ -21,18 +21,23 @@ export type RequestOptions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
class BaseApiService {
|
class BaseApiService {
|
||||||
bearerToken: string;
|
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
|
|
||||||
noAuthEndpoints: string[] = ["/auth/jwt/login", "/auth/register", "/auth/refresh"]; // Add more endpoints as needed
|
noAuthEndpoints: string[] = ["/auth/jwt/login", "/auth/register", "/auth/refresh"]; // Add more endpoints as needed
|
||||||
|
|
||||||
constructor(bearerToken: string, baseUrl: string) {
|
// Use a getter to always read fresh token from localStorage
|
||||||
this.bearerToken = bearerToken;
|
// This ensures the token is always up-to-date after login/logout
|
||||||
|
get bearerToken(): string {
|
||||||
|
return typeof window !== "undefined" ? getBearerToken() || "" : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(baseUrl: string) {
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
setBearerToken(bearerToken: string) {
|
// Keep for backward compatibility, but token is now always read from localStorage
|
||||||
this.bearerToken = bearerToken;
|
setBearerToken(_bearerToken: string) {
|
||||||
|
// No-op: token is now always read fresh from localStorage via the getter
|
||||||
}
|
}
|
||||||
|
|
||||||
async request<T, R extends ResponseType = ResponseType.JSON>(
|
async request<T, R extends ResponseType = ResponseType.JSON>(
|
||||||
|
|
@ -293,7 +298,4 @@ class BaseApiService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const baseApiService = new BaseApiService(
|
export const baseApiService = new BaseApiService(process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL || "");
|
||||||
typeof window !== "undefined" ? getBearerToken() || "" : "",
|
|
||||||
process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL || ""
|
|
||||||
);
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue