Microsoft allows you to embed previews of a document stored in SharePoint Online / OneDrive inside your site web page.
There is an API (driveItem: preview – Microsoft Graph v1.0) that allows you to obtain short-lived embeddable URL to render document preview.
Recently some of out users complained that they no longer see previews. Instead, they see very interesting message “Hmm… looks like this file doesn’t have preview we can show you”.
If you try to Google this issue you won’t find much, but if you bing it you will find few questions on MS Tech Community site that aren’t really helpful.
- Hmm looks like this file doesn’t have a preview we can show you (Sharepoint online, new templates)
- Hmm looks like this file doesn’t have a preview we can show you
- Hmm… looks like this file doesn’t have a preview we can show
Let’s open Edge/Chrome dev tools (F12) and find out what is going on. On the network tab, I found few failed requests (related to online preview) with 404 status code.
What interesting about this image is that the response comes from ServiceWorker (and not from actual backend). This means that your browser has service worker installed for SharePoint Online that intercept request to the server and reply with 404 instead of passing the request to server.
We need to find and remove service worker that break our previews.
- Open edge://serviceworker-internals/?devtools in Edge
- Or open chrome://serviceworker-internals/?devtools in Chrome
- Or go to Application > Service Workers > See all registrations
Find service worker registered for your SharePoint Online tenant (*.sharepoint.com) and Unregister it.
That it, next time when you reload page with web preview, it should work.
When you visit web preview of a document in SharePoint Online it most likely register the service worker again, but new one should not break your previews.