1

I'm working on Project using React for the frontend and Laravel for the backend using RESTfull API. I developed each one in separate directories but now I'm trying to deploy them in the same folder I don't really know what to do. or can I deploy then each one in their own folder? if yes how can I run them on the same server (apache)?

Rafaa Ferid
  • 188
  • 9

1 Answers1

0

The directory really shouldn't matter. Since React is a frontend javascript development framework, it runs on the client while the laravel backend will run on the server itself. All you need to do is serve the entry point html and the javascript file created from your react project to the client.

I assume you're thinking about the "development server" that you run while developing the react app. You need to, depending on your build environment, do a production build and serve the files in some way to the client.

When using create react app you can use the deployment build instructions: https://facebook.github.io/create-react-app/docs/deployment

So to summarise:

  • Host your laravel backend on the apache server
  • Upload entry point html (you can serve this via laravel, create a template with the correct html)
  • Serve the deployment javascript file for your react app (just include it on the same html page)
LoKat
  • 1,179
  • 10
  • 18
  • thanks for your help. if i want to serve the react and laravel both on apache how can i do it like is it possible to run each one on different port using apache – Rafaa Ferid Jan 25 '19 at 11:14
  • as I said, react is just a frontend framework. Just serve the files USING laravel. Take a look at this guide: https://blog.pusher.com/react-laravel-application/ – LoKat Jan 25 '19 at 11:49