Vadym Petryshyn Vadym Petryshyn - 1 month ago 17
PHP Question

React / Laravel (php) SPA on same (Apache) server

I want to do SPA application at the front-end will be the React, while the rest full api on laravel at the back-end. All I want to place on the same Apache server on the same domain ( myapp.com/index URLs my react application, requests will send to myapp.ru/api / ...).

Explain please, whether it is a normal practice, I understand I will have a problem with routing, and I always have to do rewrite to the index.html when page updating. Would not I have problems with the fact that I'm going to do ajax requests to the same domain as the front-end to the back-end.

Please explain that, and how that would all normally worked to configure. Or is it all a bad idea, and REACT to work on node.js server and separately laravel on apache. I would be very grateful for an explanation.

Answer

SPA application does not require a server. You build your React app using webpack or browserify and server those static bundles to the client via Apache.

All the api calls will go to your backend laravel. (myapp.ru/api)

Comments