mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 11:23:10 +02:00
Bug fixing and debugs (#5704)
Co-authored-by: ConnorYoh <[email protected]>
This commit is contained in:
co-authored by
ConnorYoh
parent
5df466266a
commit
f9d2f36ab7
@@ -122,6 +122,7 @@ export const AppConfigProvider: React.FC<AppConfigProviderProps> = ({
|
||||
}
|
||||
setError(null);
|
||||
|
||||
const startTime = performance.now();
|
||||
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
||||
try {
|
||||
const testConfig = getSimulatedAppConfig();
|
||||
@@ -142,6 +143,7 @@ export const AppConfigProvider: React.FC<AppConfigProviderProps> = ({
|
||||
|
||||
// apiClient automatically adds JWT header if available via interceptors
|
||||
// Always suppress error toast - we handle 401 errors locally
|
||||
console.debug('[AppConfig] Fetching app config', { attempt, force, path: window.location.pathname });
|
||||
const response = await apiClient.get<AppConfig>(
|
||||
'/api/v1/config/app-config',
|
||||
{
|
||||
@@ -152,6 +154,7 @@ export const AppConfigProvider: React.FC<AppConfigProviderProps> = ({
|
||||
const data = response.data;
|
||||
|
||||
console.debug('[AppConfig] Config fetched successfully:', data);
|
||||
console.debug('[AppConfig] Fetch duration ms:', (performance.now() - startTime).toFixed(2));
|
||||
setConfig(data);
|
||||
setHasResolvedConfig(true);
|
||||
setLoading(false);
|
||||
@@ -163,6 +166,7 @@ export const AppConfigProvider: React.FC<AppConfigProviderProps> = ({
|
||||
// This allows the app to work even without authentication
|
||||
if (status === 401) {
|
||||
console.debug('[AppConfig] 401 error - using default config (login enabled)');
|
||||
console.debug('[AppConfig] Fetch duration ms:', (performance.now() - startTime).toFixed(2));
|
||||
setConfig({ enableLogin: true });
|
||||
setHasResolvedConfig(true);
|
||||
setLoading(false);
|
||||
@@ -181,6 +185,7 @@ export const AppConfigProvider: React.FC<AppConfigProviderProps> = ({
|
||||
const errorMessage = err?.response?.data?.message || err?.message || 'Unknown error occurred';
|
||||
setError(errorMessage);
|
||||
console.error(`[AppConfig] Failed to fetch app config after ${attempt + 1} attempts:`, err);
|
||||
console.debug('[AppConfig] Fetch duration ms:', (performance.now() - startTime).toFixed(2));
|
||||
// Preserve existing config (initial default or previous fetch). If nothing is set, assume login enabled.
|
||||
setConfig((current) => current ?? { enableLogin: true });
|
||||
setHasResolvedConfig(true);
|
||||
@@ -203,7 +208,7 @@ export const AppConfigProvider: React.FC<AppConfigProviderProps> = ({
|
||||
// On auth pages, always skip the config fetch
|
||||
// The config will be fetched after authentication via jwt-available event
|
||||
if (isAuthPage) {
|
||||
console.debug('[AppConfig] On auth page - using default config, skipping fetch');
|
||||
console.debug('[AppConfig] On auth page - using default config, skipping fetch', { path: currentPath });
|
||||
setConfig({ enableLogin: true });
|
||||
setHasResolvedConfig(true);
|
||||
setLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user