'Black page using service workers with NX and Vercel

I am writing this post to know if anyone else has tried to add a service worker and a PWA to their application with React. In my case, I am using Vercel to do the deployments, and I have encountered a very strange bug that has forced me to delete my sw.

What happens is that when I publish the application with the SW, I have users (including me) who get a blank screen. I tried everything to solve it, but I think there must be some conflict with vercel and/or NX regarding the cache, because my application tries to access static files that no longer exist, hence the white screen.

If I refresh the screen by clearing cache (Ctrl+F5) the problem is solved, but of course, I can't ask this daily to thousands of users 🥲

I hope someone has had this problem and can give me some light. Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source