Skip to content

CORS errors when loading resources from config.json  #6259

@vladyslav571

Description

@vladyslav571

Category

  • Question
  • Typo
  • Additional article idea

Question

I have a webpart which uses external library according to (https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/basics/add-an-external-library#load-a-script-from-a-cdn). Everything works fine however I always see CORS errors when SP page tries to load this library. Also same errors are seen when SP page tries to load localizedResources from config.json.

Errors are like:
"Access to script at 'https:///development/sharepoint/v1/assets/v1-commonstrings_en-us_cc83c7b1d8f44bf102f81e223fdf4b06.js' from origin 'https://*.sharepoint.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."

I also investigated that localizedResources and external libs are loaded twice by script "https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-gb_187009d50ea1060e33206e49000cbf6e.js":

  1. first time (when it fails due to CORS) with header Sec-Fetch-Mode: cors
  2. second time (then successful) Sec-Fetch-Mode: no-cors

Environment details (development & target environment)

  • Your Developer Environment: [Chrome, Edge browser]
  • Target Environment: [SharePoint Online]
  • Framework: [spfx 1.10]
  • Browser(s): [Chrome, Edge]
  • Tooling: [e.g. VS Code | SPFx v1.10.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:spfxCategory: SharePoint Framework (not extensions related)status:answeredAnswer to a question.status:by-designTopic described is by design & not considered an issue.type:questionQuestion... if answered, will be tagged as such.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions