Add preloader and disable service worker to prevent blank screen issues
Introduces a visual preloader to the client's index.html and disables the service worker in main.tsx. Additionally, server-side middleware in index.ts is added to set no-cache headers for HTML pages, aiming to resolve the reported blank screen problem. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 890577b1-c154-40a4-a177-a0c6d55320c3 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/890577b1-c154-40a4-a177-a0c6d55320c3/DyHCx4q
This commit is contained in:
+25
-12
@@ -4,18 +4,18 @@ import "./index.css";
|
||||
|
||||
console.log('🎬 main.tsx starting...');
|
||||
|
||||
// Registracija Service Worker-ja za PWA funkcionalnost
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/sw.js')
|
||||
.then((registration) => {
|
||||
console.log('SW registered: ', registration);
|
||||
})
|
||||
.catch((registrationError) => {
|
||||
console.log('SW registration failed: ', registrationError);
|
||||
});
|
||||
});
|
||||
}
|
||||
// Disable Service Worker for now - can cause caching issues
|
||||
// if ('serviceWorker' in navigator) {
|
||||
// window.addEventListener('load', () => {
|
||||
// navigator.serviceWorker.register('/sw.js')
|
||||
// .then((registration) => {
|
||||
// console.log('SW registered: ', registration);
|
||||
// })
|
||||
// .catch((registrationError) => {
|
||||
// console.log('SW registration failed: ', registrationError);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
try {
|
||||
const rootElement = document.getElementById("root");
|
||||
@@ -32,6 +32,19 @@ try {
|
||||
root.render(<App />);
|
||||
|
||||
console.log('✅ React app mounted successfully');
|
||||
|
||||
// Remove preloader once React app has mounted
|
||||
setTimeout(() => {
|
||||
const preloader = document.getElementById('app-preloader');
|
||||
if (preloader) {
|
||||
preloader.style.opacity = '0';
|
||||
preloader.style.transition = 'opacity 0.5s ease-out';
|
||||
setTimeout(() => {
|
||||
preloader.remove();
|
||||
console.log('🎨 Preloader removed');
|
||||
}, 500);
|
||||
}
|
||||
}, 100);
|
||||
} catch (error) {
|
||||
console.error('❌ Failed to mount React app:', error);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user