CORS issues with SPFx Library Component
Category
- [x] Bug
Describe the bug
I have a new library component that exposes several shared services, components and interfaces. I am able to compile and deploy this library without issues. I have created a consumer web part that uses this shared library for access to the services it provides. When the web part is added to the page I can see the request that looks for the library component but it eventually fails with the following error:
Access to fetch at 'https://publiccdn.sharepointonline.com/<tenant>.sharepoint.com/ClientSideAssets/3199963a-1890-44f9-a2d9-63fe25f5984b/odge-library-library_cec227165a5f1b7d901e98039b13145d.js' from origin 'https://<tenant>.sharepoint.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
I have ensure that the Public CDN is enabled and the policy is defined like this:
Key Value
--- ---
IncludeFileExtensions CSS,EOT,GIF,ICO,JPEG,JPG,JS,MAP,PNG,SVG,TTF,WOFF,WOFF2
ExcludeRestrictedSiteClassifications
ExcludeIfNoScriptDisabled False
Expected behavior
The consumer web part should consume the library component and get access to the controls and services is provides.
Environment details (development & target environment)
- SharePoint Online
- SPFx 1.11.0
Additional context
I have tried these two components in multiple tenants and get the same result.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
This has been resolved.
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues