DEV Community

Kelvin Kiptum Kiprop
Kelvin Kiptum Kiprop

Posted on Edited on

The Case of the Blank SharePoint Page (and the Guest Who Couldn't See It)

SPFx web part and application customizer not loading for guest or external users, and the Public CDN fix

TL;DR: Guests can't read your SPFx bundles from the app catalog, so the page renders blank. Enable the Public CDN with the */CLIENTSIDEASSETS origin (or grant the guest read on the app catalog), wait until it goes active, bump the version and redeploy the .sppkg, then retest as the guest in InPrivate. Ignore the ReadCacheOrCreate2 500: it's a decoy.

This post assumes: a tenant-wide app catalog, includeClientSideAssets: true in config/package-solution.json, a modern SharePoint site, and a B2B guest (for example, a Gmail account). Site collection app catalogs behave differently.

We built a shiny intranet home page as an SPFx solution: a web part for the page body and an application customizer for the header and footer. Internal users loved it. Then we invited a Gmail guest to test external sharing, and they got a big beautiful nothing.

Here's how we tracked down the culprit, the wrong turns we took, and the fix that finally worked.

The crime scene

For the guest, SharePoint showed its stock chrome and an empty canvas.

A SharePoint site home page with the header and command bar visible and a completely empty page body.

Caption: What the guest sees: SharePoint chrome, empty canvas.

POST /sites/<site>/_api/SP.UserProfiles.PersonalCache/ReadCacheOrCreate2
CannotCreatePersonalSite : You do not have access to create this personal site.
Enter fullscreen mode Exit fullscreen mode

"Cannot create personal site" sounds like the smoking gun. It isn't.

Suspect #1: the red herring

That call is SharePoint's first-run-experience cache. It tries to write to the signed-in user's OneDrive. Guests don't have OneDrive, so it fails for every guest on every page, with or without web parts.

We kept seeing this error after the real bug was fixed. Lesson: don't judge a fix by that 500. The only test that matters is whether the page renders.

The real clue (hiding in the console)

Further down the console, the browser dropped a few gems. These are the messages to search for if your page is blank:

Refused to execute script from '<URL>' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Could not load <your-component> in require. Error: Script error for "<component-id>_1.0.0"

Uncaught (in promise) Error: Failed to create application customizer 'ClientSideExtension.ApplicationCustomizer.<id>'. Error information is 'Extension failed to load for componentId "<id>".'
Enter fullscreen mode Exit fullscreen mode

Browser console showing a 500 error on a POST request, a refused-to-execute-script error for text/html, and errors that the web part and application customizer failed to load.

Caption: One decoy, one real clue, and the symptoms it caused.

The Refused to execute line is the one that matters. In DevTools, it may show <URL>, so expand the message or open the Network tab to see the full address. The full message looks like this:

Refused to execute script from
    'https://<tenant>.sharepoint.com/sites/appcatalog/_layouts/15/AccessDenied.aspx?Source=...
    /sites/appcatalog/ClientSideAssets/.../my-web-part_<hash>.js' because its MIME type ('text/html') is not executable
Enter fullscreen mode Exit fullscreen mode

Translation: the browser requested the web part's JavaScript but received an "Access Denied" page instead. The Source= parameter tells you exactly which file it wanted.

So what's going on?

  • With includeClientSideAssets: true in config/package-solution.json, the .sppkg carries its JS bundles.
  • Deploy it to the tenant app catalog and those bundles live in that site's ClientSideAssets library.
  • By default, pages load them straight from there.
  • Your internal people can read the app catalog site. Your guest cannot. Door closed, page blank.
  • Both the web part and the application customizer load this way, so both fail together.

Suspect #2: the Private CDN (a swing and a miss)

Our first idea: turn on the Office 365 Private CDN and add */CLIENTSIDEASSETS as an origin.

Set-SPOTenantCdnEnabled -CdnType Private -Enable $true
Add-SPOTenantCdnOrigin -CdnType Private -OriginUrl */CLIENTSIDEASSETS
Enter fullscreen mode Exit fullscreen mode

We waited out the "(configuration pending)" status. We redeployed the package. We refreshed like champions. Same /sites/appcatalog/ClientSideAssets/ URLs, same AccessDenied.

The Private CDN simply doesn't take over these bundles. No amount of waiting or redeploying was going to change that. Moving on.

The fix: the Public CDN

SPFx ClientSideAssets get served from the Public CDN, where */CLIENTSIDEASSETS is a standard origin. Flip that on and the guest's page springs to life.

  1. Check the current state first. You need the SharePoint Administrator or Global Administrator role. The Public CDN may already be enabled on your tenant, in which case the problem is a missing origin or a package deployed before it went live.
Connect-SPOService -Url https://<tenant>-admin.sharepoint.com
Get-SPOTenantCdnEnabled -CdnType Public
Get-SPOTenantCdnOrigins -CdnType Public
Enter fullscreen mode Exit fullscreen mode
  1. Enable it if it's off.
Set-SPOTenantCdnEnabled -CdnType Public -Enable $true
Enter fullscreen mode Exit fullscreen mode
  1. Check that */CLIENTSIDEASSETS is in the Public origins list. If it's missing, add it:
Add-SPOTenantCdnOrigin -CdnType Public -OriginUrl */CLIENTSIDEASSETS
Enter fullscreen mode Exit fullscreen mode
  1. Grab a coffee until "(configuration pending)" disappears. Think roughly 15 minutes.

  2. Redeploy the .sppkg. Bump the version, rebuild, upload to the app catalog, click Deploy. Asset URLs are baked in at deploy time, so a package deployed before the origin went live keeps its old, broken URLs.

  3. Test as the guest in an InPrivate window with DevTools open and Disable cache ticked.

Embedded content: bundle request paths · app catalog vs Public CDN

The app catalog path returns an Access Denied page the browser refuses to run; the Public CDN path serves the script.

The page rendered. Victory dance optional but encouraged.

How you know it worked

Don't trust a hunch. Check all three:

  • The page renders for the guest, web part and header and footer included.
  • The Network tab shows the bundle requests going to publiccdn.sharepointonline.com and returning 200, instead of /sites/appcatalog/ClientSideAssets/.
  • The console no longer shows Refused to execute script.

The ReadCacheOrCreate2 500 will still be there. That's expected. Remember the decoy.

Plan B: just let the guest in

You can also add the guest as a Visitor on the app catalog site (Active sites > appcatalog > Membership > Visitors). It's a great way to confirm your diagnosis in two minutes, and it's fine for a handful of trusted guests. But it doesn't scale: you're opening up a site you probably want private, one guest at a time.

Plan C: host the bundles yourself

If your tenant admin won't enable the Public CDN, you can serve the bundles from somewhere else. Set includeClientSideAssets to false, set a cdnBasePath in config/write-manifests.json, and upload the built files to a host that allows anonymous reads, such as Azure Blob Storage behind Azure CDN. Then deploy the package as usual. The same warning applies: whatever is anonymously readable is public.

Read this before you flip the switch

  • Your bundles become publicly fetchable. Anyone with the CDN URL can download the JavaScript without signing in. The URLs are hard to guess, but they are not secret, so treat them as public. Keep secrets, API keys, and private tenant data out of your bundle. (Ours holds no keys; a backend proxy does.)
  • It's tenant-wide. The CDN applies to every SPFx solution in the tenant, and Microsoft itself warns it sits outside the usual Microsoft 365 compliance boundary. Check with whoever owns your data policy.
  • Order matters. Enable the origin, let it go active, then deploy the package.

The cheat sheet

  1. Ignore ReadCacheOrCreate2 for guests. It's a decoy.
  2. Hunt for Refused to execute script ... AccessDenied.aspx in the console.
  3. Read the Source= URL to see where the bundle is being served from.
  4. If it's /sites/<appcatalog>/ClientSideAssets/..., the guest can't reach it. Either serve it from the Public CDN, host it yourself, or grant read on the app catalog.
  5. Check Get-SPOTenantCdnEnabled -CdnType Public and the origins list before changing anything.
  6. After every change, redeploy the package and retest in a fresh InPrivate window.

Happy shipping, and may your canvases never be blank.

Top comments (1)

Collapse
 
launchgatecheck profile image
Launch Gate •

The ReadCacheOrCreate2 decoy deserves its own triage rule: an error that also fires on pages where everything works cannot be the cause of this page failing. Before reading a single stack, reproduce the suspect in the passing state - same guest, a page with no web parts. If the 500 shows up there too, it's background noise and you can stop reading it. That ten-second check crosses off suspect #1 before it costs any time. The MIME-type clue is worth naming as a class, too: "expected a script, got text/html" is almost always a server that answered with an error page dressed in a 200. Permission failures on the web rarely say no - they return a login or AccessDenied page where content was expected, and strict MIME checking is the only reason the browser mentions it. The Source= parameter is the confession: it names the file that was actually refused.