Hosting client-side web part from Office 365 CDN
Category
- [x] Question
- [ ] Typo
- [ ] Bug
- [ ] Additional article idea
I'm trying to host a client-side web part from localhost to CDN, but I'm getting this error:

Get-SPOTenantCdnOrigins -CdnType Public commands in Powershell gives me the following result:
Public CDN enabled locations: */MASTERPAGE */STYLE LIBRARY */CLIENTSIDEASSETS
It works fine in localhost enviroment. I followed all the steps from Microsoft's article on an overview of the SharePoint Framework, but to no avail. How would I fix this?
If you navigate to https://bhowmiksolutions.sharepoint.com/sites/cat/ClientSideAssets/, can you see the file in there?
I got the same issue too. I can navigate to that folder and see the files for my web part. When I try to add my web part I can't see my web part and an error message is displayed. Works fine in a local environment for me too.
Something went wrong If the problem persists, contact the site administrator and give them the information in Technical Details.
TECHNICAL DETAILS [SPLoaderError.loadComponentError]: ***Failed to load component "ad2d1bb3-4545-4887-bff6-d8108673a431" (HelloWorldWebPart). Original error: ***Failed to load URL 'https://publiccdn.sharepointonline.com/3sa2ahujf.sharepoint.com/sites/apps/ClientSideAssets/a4749a6e-92ef-4c25-9f0c-1da62f722c26/helloworld-webpart-helloworldwebpartstrings_en-us_536e65149b0acf4d52c0043073b9fc59.js' for resource 'HelloWorldWebPartStrings' in component 'ad2d1bb3-4545-4887-bff6-d8108673a431' (HelloWorldWebPart). There was a problem in the server.
***INNERERROR: ***Failed to load URL 'https://publiccdn.sharepointonline.com/3sa2ahujf.sharepoint.com/sites/apps/ClientSideAssets/a4749a6e-92ef-4c25-9f0c-1da62f722c26/helloworld-webpart-helloworldwebpartstrings_en-us_536e65149b0acf4d52c0043073b9fc59.js' for resource 'HelloWorldWebPartStrings' in component 'ad2d1bb3-4545-4887-bff6-d8108673a431' (HelloWorldWebPart). There was a problem in the server. ***CALLSTACK: Error at t [as constructor] (https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-02-02.010/sp-pages-assembly_en-us_2bcc5fa1511fb845670c6d5304ff38a3.js:288:15468) at new t (https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-02-02.010/sp-pages-assembly_en-us_2bcc5fa1511fb845670c6d5304ff38a3.js:701:36434) at Function.e.buildErrorWithVerboseLog (https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-02-02.010/sp-pages-assembly_en-us_2bcc5fa1511fb845670c6d5304ff38a3.js:701:42137) at Function.e.buildLoadComponentError (https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-02-02.010/sp-pages-assembly_en-us_2bcc5fa1511fb845670c6d5304ff38a3.js:701:38717) at https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-02-02.010/sp-pages-assembly_en-us_2bcc5fa1511fb845670c6d5304ff38a3.js:701:11286 at
Yes I can navigate to the folder and see the files.
I wonder if for some reason the files haven't been propagated to the CDN correctly. You could try a few things:
- remove the web part, verify that files are gone from the folder, redeploy the web part, verify that files are in the folder, see if things are working
- remove the */clientsideassets origin and add it again and see if that changes anything
Is it only this one web part that's affected or is nothing loading from the CDN?
When I removed web part its disappeared all files from Client Side Assets. Redeploying web part brings all the files back in Client Side Assets. Its not only this web part is affecte and nothing is loading from the CDN.
In powershell, Get-SPOTenantCdnPolicies -CdnType Public give me following results.
Key Value
--- -----
IncludeFileExtensions CSS,EOT,GIF,ICO,JPEG,JPG,JS,MAP,PNG,SVG,TTF,WOFF
ExcludeRestrictedSiteClassifications ExcludeIfNoScriptDisabled False
is it ok?
Those are the default settings for the CDN - would also double check that the CDN is enabled by using Get-SPOTenantCdnEnabled -CdnType Public. If that returns true, we might have a bug in the propagation.
Also - what's your setting for the includeClientSideAssets in the package-solution.json? - is that true or false. There are few things which still could go wrong, but would get above details and we can then solve if this is an issue on the actual CDN or in the settings in your solution. Thx.
Get-SPOTenantCdnEnabled -CdnType Public True includeClientSideAssets True
Is my settings.
Get-SPOTenantCdnEnabled -CdnType Public
Value
True
"includeClientSideAssets": true
Thanks.
Did you make it work rkbhowmik?
Have you tried removing and re-adding the */clientsideassets origin?
Yes. Problem still remains.
Thanks for checking @rkbhowmik. I'm afraid I don't have any other suggestions at this moment. Any suggestions for next steps @VesaJuvonen?
Hi Waldek, thanks for your engagement and your advices, however I may misunderstood one of your suggestions i.e. removing and re-adding the */clientsideassets origin. Can you please let me know exactly how to do it? Thanks again. @waldekmastykarz
Here is more information on removing and configuring the CDN origins: https://docs.microsoft.com/en-us/sharepoint/dev/general-development/office-365-cdn#remove-office-365-cdn-origin
Hello again, I have tried to solve the problem by removing and configuring the CDN origins but problem still remains. @waldekmastykarz
Thanks for checking @rkbhowmik and sorry to hear it's not solved. @VesaJuvonen: any additional info that we could gather to help @rkbhowmik debug this issue?
It was a problem in tenant settings @waldekmastykarz . Powershell code for allowing user to use customs script makes problem.
You mean the no-script setting @rkbhowmik?
@rkbhowmik can you clarify slightly more on what you mean with this. You can use SPFx web parts regardless of the no-script settings if that was what you were referring to. We would definitely appreciate additional input on understanding what exactly was the problem. Thx.
$adminUPN="[email protected]" $orgName="xxxxxxxx" $userCredential = Get-Credential -UserName $adminUPN -Message "Type the password." Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential Set-SPOsite https://xxxxxxxx.sharepoint.com -DenyAddAndCustomizePages 0
Instead of 0, I have written 1, so it didn't allow user to use custom scripts. I have also tried remove and enable office 365 CDN origin.