fix: Make network detection more lenient for reverse proxy environments
Changed network detection to only mark as offline on actual network errors, not on HTTP errors like 404. This fixes the issue where the app shows 'You are offline' even when connected, which happens when accessing through a reverse proxy where the /api/health endpoint might not be properly routed. Now the app will show as online as long as it can reach the server (any HTTP response), and only show offline on true connection failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -148,6 +148,9 @@ const withPWA = require('next-pwa')({
|
|||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
|
|
||||||
|
// Allow access through reverse proxy
|
||||||
|
assetPrefix: process.env.NODE_ENV === 'production' ? undefined : undefined,
|
||||||
|
|
||||||
// Performance optimizations
|
// Performance optimizations
|
||||||
compiler: {
|
compiler: {
|
||||||
removeConsole: process.env.NODE_ENV === 'production',
|
removeConsole: process.env.NODE_ENV === 'production',
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -66,13 +66,11 @@ export const setupNetworkDetection = (dispatch: any) => {
|
|||||||
});
|
});
|
||||||
const latency = Date.now() - startTime;
|
const latency = Date.now() - startTime;
|
||||||
|
|
||||||
if (response.ok) {
|
// Consider online if we got ANY response (even 404)
|
||||||
dispatch(setOnlineStatus(true));
|
// Only mark offline on actual network errors
|
||||||
// You could also dispatch latency here
|
dispatch(setOnlineStatus(true));
|
||||||
} else {
|
|
||||||
dispatch(setOnlineStatus(false));
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// Only network errors (no connection) should mark as offline
|
||||||
dispatch(setOnlineStatus(false));
|
dispatch(setOnlineStatus(false));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user