How Can I Fix CORS Issues on My Azure Static Web App?

0
27
Asked By CuriousCoder89 On

I'm currently encountering CORS errors with my Azure Static Web App. I have a backend API hosted on Azure Web App at https://hello2341.azurewebsites.net, and my frontend UI is located at https://frontend456.azurewebsites.net. However, I'm struggling to find a CORS setting in the Azure portal for the Static Web App. My UI application is built using Vite React, and I'm looking for suggestions on how to solve this problem. Any help would be appreciated!

2 Answers

Answered By CloudGuru88 On

Are you managing CORS in your backend API as well? Most backends have a CORS option that you can enable. I've seen teams needing to configure CORS settings on their backend to solve these issues. You might want to check that out!

ApiWhisperer123 -

We're not currently handling CORS on our backend. I know Azure Web Apps have a CORS option, but the Static Web App doesn't seem to offer one.

Answered By TechSavvy2023 On

You can set up CORS headers in your static web app using the configuration file. Check the global headers section or add them specifically to a route as needed. However, keep in mind that CORS issues might not be resolved just by adding headers to the static site, since it should ideally serve content from the same origin as your requests. Can you share the specific CORS error you're seeing and what domain it's trying to access?

FrontendDev99 -

To deploy your app, you can use the Azure static web apps action in your YAML file. Make sure your staticwebapp.config.json is in the dist folder for it to work properly!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.