Q: Configure CORS for Azure Static Web Apps (preview)

Viewed 3031

I deploy artifacts like images, CSS and JavaScript bundles to an Azure Static Web App (Preview). If I consume a JavaScript bundle from another site I get CORS errors. In the Azure configuration for Static Web App (Preview) there is no option to configure CORS. Any idea on how to configure CORS?

2 Answers

Suggestion

  1. If the operation is similar to mine, the cors problem still occurs, then I suggest you raise a support ticket on the portal. In theory, this problem should not exist.

  2. If there is a problem with my reproduction steps, or if it is convenient for you, you can create and provide me with a link to your test file (for example, test.js), and I will test it again.

PRIVIOUS

After reading your question carefully again, I think this question shouldn't arise.

Normally, when we successfully publish our static web app program, we can directly access our static resources, such as .js files.

Currently you have an issue, so I tried it and wanted to reproduce your issue. If there is a step that is inconsistent with you, please let me know. We solve this problem together.

Here are my steps to reproduce:

  1. Create the myStaticWeb project, which contains the css and js folders, and the index.html file. As the main project of my Static web app, the jquery.js file in the js folder is used as the source file for cdn.

enter image description here

  1. After publishing to github, the file directory is as follows.

    The path of the jquery.js file is https://proud-dune-0b3b7a110.azurestaticapps.net/js/jquery.js.

    You can also access it directly.

enter image description here

  1. Create another static web app or .net core web app for testing.

enter image description here

enter image description here

enter image description here

enter image description here

Related