CORS errors when trying to run a react-based app that makes wordpress REST API calls to another subdomain


#1

I have a website a wordpress website I made a couple years ago at jackalope.tech

I have decided to make a new website using a headless-wordpress server-side-rendered react-based single-page-application at hire-me.jackalope.tech.

I’m using a framework called frontity.

I am encountering CORS errors when I click any link that takes the user to a page (rather than wordpress post). The javascript console says that it’s a CORS error. But I have set up the .htaccess to allow for CORS on both the subdomain hire-me.jackalope.tech and the main website at jackalope.tech. But I am still getting these CORS errors. At first I thought that it was a problem with the framework itself but I switched it to grab it’s REST-API data from the frontity test server… and nothing is wrong… it works perfectly… so the problem must be with the dreamhost server then right?

Any ideas on how to fix this?

EDIT

I was able to eventually fix this by adding the following to the htaccess:

Header add Access-Control-Allow-Methods: "*"
Header add Access-Control-Allow-Headers: "*"

There is an additional line in the Dreamhost documentation that screws things up for some reason. I have no clue why.

Docs should be updated. :persevere:


#2

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.