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 *

You May Also Like…

Toggen builds a new website

So I have built and hosted a new website for Roger Clark Pest Management they are a family owned and operated Pest...

WizTree

Just downloaded WizTree (not a sponsor) from https://wiztreefree.com/ It seems to do what it says on the tin which is...

Scam call from “Telstra”

Just had a call from a man with a sub-continental accent from caller ID 0734946596 Told me there was problem with my...