My React application running on Azure Static web app as a front end and wordpress running on web app services as banckend i am having CORS policy isssue

Kunal Kumar 0 Reputation points
2023-04-04T07:03:32.7633333+00:00

My React application running on Azure Static web app as a front end and wordpress running on web app services as banckend i am having CORS policy isssue

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,931 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,173 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-04-07T17:00:56.69+00:00

    the word press site needs to enable CORS. If you can not enable CORS, then you might want to configure an api proxy on the static website

    1 person found this answer helpful.
    0 comments No comments

  2. Grmacjon-MSFT 19,151 Reputation points Moderator
    2023-04-12T22:08:06.8833333+00:00

    Hello @Kunal Kumar Checking to see if you're still facing this issue. To fix the CORS policy issue between your React frontend and WordPress backend, you need to enable CORS on your WordPress backend. Here are the steps to enable CORS on WordPress:

    1. Install the "Enable CORS" plugin in your WordPress site.
    2. Activate the plugin and go to the settings page of the plugin.
    3. On the settings page, you will find the "Access-Control-Allow-Origin" option. Add the URL of your React app (e.g., https://myreactapp.azurestaticapps.net) to this option.
    4. Save the settings and restart your WordPress site. After enabling CORS on your WordPress backend, your React frontend should be able to make requests to your WordPress backend without any CORS policy issue. Hope that helps. -Grace
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.