CodeIgniter 4 RESTful API and React JS on shared host.
This is a rudimentary code experiment on how to:
- use CodeIgniter 4 with shared hosting, like a WordPress installation;
- provide an RESTful API with JWT authentication;
- and a React front end to authenticate the user and consume that API.
The "doc" folder contains a copy of the CodeIgniter and Devilbox ".env" files, where the characteristics of the project environment can be consulted.
- The "devilbox.env" is the .env file in the root of Devilbox's git directory.
- The "codeigniter.env" is the .env file in the CodeIgniter's "backend" directory.
The .env files were included in the Git commits for educational purposes.
It is advisable to add the ".env" files to the ".gitignore" of the project. Obviously .env files should not be committed if they contain information that compromises the safety of the project.
Some info: Please don't commit .env (https://dev.to/somedood/please-dont-commit-env-3o9h).
- The code has been changed to be compatible with react-router-dom v6.
- The "backend" folder contains the CodeIgniter files.
- The files from CodeIgniter's "public" folder have been moved to the root of the application, outside of the "backend" folder.
- The "frontend" folder contains the source code files of front-end app (and does not need to be sent for the hosting server). This source code is packed to /public/dist/ folder.
- The "public" folder at the root is a suggestion of where the front-end assets might reside.
- ".htaccess" files apply some access restrictions to the contents of the "frontend" and "backend" folders.
Inspired by OLUYEMI OLUSUSI's tutorials: