Tips to using CakePHP 3.x as a ReactJS API backend

Written by James McDonald

January 5, 2018

Information for React I found useful

https://auth0.com/blog/secure-your-react-and-redux-app-with-jwt-authentication/ this had a sample project that showed how to setup redux and react and explains the redux ecosystem of store, actions, action creators, reducers etc.

It has a nice example of redux middleware ( check out the source and look in middleware/api.js )

Configure CakePHP 3.x

First follow the direction in the bravo-kernel series here:

http://www.bravo-kernel.com/2015/04/how-to-build-a-cakephp-3-rest-api-in-minutes/

Starting with the above there is a chain of posts that take you from start to finish of getting CakePHP API ready.

If using Chrome and the fetch() method you will run into all sort of 501 OPTION not supported errors when trying to get access to your CakePHP API from React

This posting makes a very clean fix:

Responding to HTTP OPTIONS requests in CakePHP

You will need to have some understanding of how to integrate it into CakePHP because it is very nifty middleware: https://book.cakephp.org/3.0/en/controllers/middleware.html#using-middleware

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Clear HSTS Settings in CHrome

Open chrome://net-internals/#hsts enter the domain in the query field and click Query to confirm it has HSTS settings...

Ubuntu on Hyper-v

It boils town to installing linux-azure # as root or sudo apt-get update apt-get install linux-azure...