Answer the question
In order to leave comments, you need to log in
Create-React-App and Laravel. How to use correctly?
Hello!
The question is most likely for those who have used create-react-app with popular php frameworks like laravel.
I'll try to explain what I want.
Here I have an application in react, which I built using create-react-app.
When the application is launched, it rises to localhost:3000, in the application config I specify the proxy from the backend url, to
access the laravel api.
Now the architecture is:
-..(lara folders)
-..(lara folders)
-react
--node_modules
--public
--src
I want to replace react/public/index.html output with resources/views/index.blade.php , and use server-side data, such as analytics, or authorization status in the template engine itself.
And I can't figure out how to implement it correctly. Previously, when I configured webpack myself, I simply moved the scripts to laravel's public folder. And in the index.blade.php itself, I just wrote the path for the scripts.
I hope I didn't explain badly. Thanks for the help.
Answer the question
In order to leave comments, you need to log in
create-react-app opens creates its own server other than laravel. It is not possible to connect them.
Use laravel as an API.
RestAPI, CORS technologies
Use laravel-mix?
You put js files in resources/assets, in webpack.mix.js you specify where the file/s will be (will be) after assembly
. Open routes/web.php and paste:
Route::any('{all}', function () {
return view('main');
})->where(['all' => '.*']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question