简体   繁体   中英

React Laravel deployment

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)?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM