SOLVED

How to disable public CDN for particular site collection?

%3CLINGO-SUB%20id%3D%22lingo-sub-138408%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20disable%20public%20CDN%20for%20particular%20site%20collection%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-138408%22%20slang%3D%22en-US%22%3E%3CP%3EYou're%20welcome!%3C%2FP%3E%0A%3CP%3EOn%20your%20Office%20365%20CDN%20remove%20the%20default%20origin%20for%20masterpage%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ERemove-SPOTenantCdnOrigin%20-CdnType%20Public%20-OriginUrl%20*%2FMASTERPAGE%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20will%20remove%20the%20default%20CDN%20origin%20with%20wildcard%2C%20which%20will%20be%20for%20every%20site%20collection%20in%20your%20tenant%20(remove%20others%20to%20if%20necessary%20like%20*%2FSTYLE%20LIBRARY).%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAdd%20a%20new%20origin%20with%20a%20OriginUrl%20pointing%20to%20the%20site%20collection%20and%20master%20page%20gallery%20location%20Like%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22%22%3E%3CSPAN%3EAdd-SPOTenantCdnOrigin%20-CdnType%20public%20%3C%2FSPAN%3E-OriginUrl%20sites%2Fyoursitecollection%2F_catalogs%2Fmasterpage%3C%2FPRE%3E%0A%3CP%3EThis%20way%20you%20have%20configured%20only%20your%20site%20collection%20masterpage%20catalog%20to%20be%20a%20CDN%20enabled%20library.%20You%20could%20also%20point%20it%20to%20a%20folder%20in%20your%20library%20to%20scope%20it%20more%20specific.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHope%20this%20helps!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-138399%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20disable%20public%20CDN%20for%20particular%20site%20collection%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-138399%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20replying..!!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20site%20collection%20where%20my%20custom%20master%20page%20has%20been%20applied%20and%20the%20site%20where%20I%20am%20deploying%20the%20SPFx%20web%20parts%20are%20different.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%2C%20I%20want%20the%20solution%20where%20I%20can%20run%20the%20SPFx%20web%20part%20from%20Office%20365%20CDN%20and%20the%20custom%20master%20page%20does%20not%20affected%20in%20another%20site%20collection.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-138128%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20disable%20public%20CDN%20for%20particular%20site%20collection%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-138128%22%20slang%3D%22en-US%22%3E%3CP%3EMaybe%20you%20could%20add%20your%20SPFx%20assets%20into%20a%20subfolder%20in%20the%20Masterpage%20gallery%20and%20Add%20that%20folder%20as%20a%20CDN%20origin%2C%20using%20Add-SPOTenantCdnOrigin.%20Remove%20the%20generally%20added%20Cdn%20origin%20to%20the%20Masterpage%20gallery.%20This%20way%20only%20the%20assets%20in%20the%20subfolder%20are%20CDN%20enabled.%20As%20mentioned%20use%20Remove-SPOTenantCdnOrigin%20to%20remove%20the%20on%20pointing%20to%20the%20Masterpage%20gallery.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENext%20to%20this%20you%20could%20also%20create%20a%20Cdn%20origin%20pointing%20to%20a%20specific%20site%2C%20instead%20of%20using%20a%20wildcard%20and%20doing%20this%20for%20all%20sites.%20Use%20a%20originUrl%20in%20this%20format%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22%22%3E-OriginUrl%20sites%2Fsite1%2Fsiteassets%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-138090%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20disable%20public%20CDN%20for%20particular%20site%20collection%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-138090%22%20slang%3D%22en-US%22%3E%3CP%3EMaster%20pages%20gallery%20is%20added%20by%20default%20as%20a%20CDN%20endpoint%20when%20public%20CDN%20is%20enabled.%26nbsp%3BTo%20remove%20it%20from%20public%20CDN%2C%20use%20the%26nbsp%3B%3CSTRONG%3ERemove-SPOTenantCdnOrigin%3C%2FSTRONG%3E%20PowerShell%20command.%3C%2FP%3E%0A%3CP%3EThis%20change%20will%20be%20applied%20to%20all%20site%20collections%20as%20it's%20a%20tenant%20setting.%20I%20don't%20think%26nbsp%3Byou%20can%20set%20distinct%20settings%20per%20site%20collection.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1072888%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20disable%20public%20CDN%20for%20particular%20site%20collection%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1072888%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F18690%22%20target%3D%22_blank%22%3E%40Robert%20Schouten%3C%2FA%3E%2C%3C%2FP%3E%3CP%3EWe%20lost%20SharePoint%20icon%20from%20apps%20list%20in%20Office%20365!%26nbsp%3B%3C%2FP%3E%3CP%3EOf%20course%20we%20have%20access%20to%20admin%20center%20and%20all%20websites.%3C%2FP%3E%3CP%3EWhat%20do%20you%20think%3F%20How%20did%20it%20happen%20and%20how%20can%20bring%20it%20back%20to%20the%20list%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1575340%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20disable%20public%20CDN%20for%20particular%20site%20collection%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1575340%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F103451%22%20target%3D%22_blank%22%3E%40Mohemmad%20Kalva%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1577433%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20disable%20public%20CDN%20for%20particular%20site%20collection%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1577433%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F103451%22%20target%3D%22_blank%22%3E%40Mohemmad%20Kalva%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1579583%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20disable%20public%20CDN%20for%20particular%20site%20collection%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1579583%22%20slang%3D%22en-US%22%3Eoi%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1588698%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20disable%20public%20CDN%20for%20particular%20site%20collection%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1588698%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F103451%22%20target%3D%22_blank%22%3E%40Mohemmad%20Kalva%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1620307%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20disable%20public%20CDN%20for%20particular%20site%20collection%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1620307%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F103451%22%20target%3D%22_blank%22%3E%40Mohemmad%20Kalva%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20will%20like%20this%20idea%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-138022%22%20slang%3D%22en-US%22%3EHow%20to%20disable%20public%20CDN%20for%20particular%20site%20collection%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-138022%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20implemented%20on%20master%20page%20in%20which%20I%20had%20referenced%20the%20css%20and%20js%20file%20using%20relative%20URLs%20to%20the%20site.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20that%2C%20I%20enabled%20the%20public%20CDN%20for%20Office%20365%20to%20deploy%20the%20SPFx%20components.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20visited%20the%20site%20where%20I%20had%20implemented%20the%20custom%20master%20page%20and%20layouts%2C%20I%20found%20that%20the%20relative%20URLs%20are%20now%20pointing%20to%20the%20CDN%20and%20the%20site%20stopped%20working.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20do%20I%20disable%20this%20behavior%3F%20i.e.%20I%20want%20to%20deploy%20the%20assets%20of%20SPFx%20to%20the%20public%20cdn%20but%20the%20existing%20implementation%20of%20the%20master%20page%20should%20not%20get%20affected%20if%20given%20the%20relative%20URLs%20for%20the%20files.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20suggest%20me%20the%20steps.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I have implemented on master page in which I had referenced the css and js file using relative URLs to the site.

 

After that, I enabled the public CDN for Office 365 to deploy the SPFx components. 

 

When I visited the site where I had implemented the custom master page and layouts, I found that the relative URLs are now pointing to the CDN and the site stopped working.

 

How do I disable this behavior? i.e. I want to deploy the assets of SPFx to the public cdn but the existing implementation of the master page should not get affected if given the relative URLs for the files.

 

Please suggest me the steps.

10 Replies
Highlighted

Master pages gallery is added by default as a CDN endpoint when public CDN is enabled. To remove it from public CDN, use the Remove-SPOTenantCdnOrigin PowerShell command.

This change will be applied to all site collections as it's a tenant setting. I don't think you can set distinct settings per site collection.

Highlighted

Maybe you could add your SPFx assets into a subfolder in the Masterpage gallery and Add that folder as a CDN origin, using Add-SPOTenantCdnOrigin. Remove the generally added Cdn origin to the Masterpage gallery. This way only the assets in the subfolder are CDN enabled. As mentioned use Remove-SPOTenantCdnOrigin to remove the on pointing to the Masterpage gallery. 

 

Next to this you could also create a Cdn origin pointing to a specific site, instead of using a wildcard and doing this for all sites. Use a originUrl in this format:

 

-OriginUrl sites/site1/siteassets
Highlighted

Thanks for replying..!!

 

The site collection where my custom master page has been applied and the site where I am deploying the SPFx web parts are different.

 

So, I want the solution where I can run the SPFx web part from Office 365 CDN and the custom master page does not affected in another site collection.

Highlighted
Best Response confirmed by Mohemmad Kalva (Occasional Contributor)
Solution

You're welcome!

On your Office 365 CDN remove the default origin for masterpage:

 

Remove-SPOTenantCdnOrigin -CdnType Public -OriginUrl */MASTERPAGE

 

This will remove the default CDN origin with wildcard, which will be for every site collection in your tenant (remove others to if necessary like */STYLE LIBRARY). 

Add a new origin with a OriginUrl pointing to the site collection and master page gallery location Like:

 

Add-SPOTenantCdnOrigin -CdnType public -OriginUrl sites/yoursitecollection/_catalogs/masterpage

This way you have configured only your site collection masterpage catalog to be a CDN enabled library. You could also point it to a folder in your library to scope it more specific.

 

Hope this helps!

Highlighted

Hi @Robert Schouten,

We lost SharePoint icon from apps list in Office 365! 

Of course we have access to admin center and all websites.

What do you think? How did it happen and how can bring it back to the list?

Highlighted
Highlighted
Highlighted
Highlighted
Highlighted