Question

How do I deploy React App along with headless WordPress CMS.

I have a React App that was created using the created-react-app boilerplate. The react app is fetching data from a WordPress API. Now I intend to deploy both the front-end and the back-end on my DO droplet that is already hosting multiple domains. How do I achieve this?

Here is what i already tried:

  1. I put the front-end files inside /var/www/abc.com
  2. I created a directory named **api ** inside /var/www/abc.com and put all the wordpress files inside that directory.
  3. I had a .htaccess file inside /var/www/abc.com so that all requests are routed through index.html
  4. My WordPress is configured. But when I access **http://abc.com/api/wp-json/wp/v2/posts ** it redirects to a 404 page.

Please help solving the issue. Thanks in advance.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Did you ever get an answer about this. What I do is use a sub domain for Wordpress, but I would like to use the same domain an make resquests from React to Wordpress as localhost