I have built a website. The front and back end are COMPLETELY separate. The front end is all REACT.JS and the back is a REST API service written in php with slim 3. The entire communication between the front end and the back end is through JSON with react consuming API routes and also the routes are JWT protected.
When I'm deploying the app to the production,I can't figure out that how can I serve an entry point to my REACT front end from my server which is running the slim 3 REST back end. I understand that if it was a typical MVC, I could render views through a templating engine such as Twig.
After building my REACT front end, the entire list of components gets compiled to a single JavaScript resource that essentially acts as an entry point to the front end.
- Is there a way that I can take this final compiled JS resource and present it to the browser on an API route( Eg: '/') so that an entry can be provided to my app frontend?
- If not, then what should I do with this compiled JS resource?
create-react-appyou can just runnpm run-script buildto build the app. It will give you a folder with final HTML and JS files.You can host it on a server. As I understood This is what you are looking for ?Slim 3code-base as a static asset or something, for example on the/UIroute, so that you don't have to host the front-end separately ? is this is case ? I haven't tried Slim before, but i've usedLaravel,Laravelhas support forVueJSout of the box you can checkout how Laravel does that withVuemaybe you will figure out something.