Home > other >  Can I run my Node.js/Express backend and React.js frontend together in the same file structure?
Can I run my Node.js/Express backend and React.js frontend together in the same file structure?

Time:01-25

I am making a web app that uses a Node.js/Express backend and a React.js Frontend. Right now I have my Node.js code that validities login/registration credentials in a separate folder running on localhost:5000 while my React.js frontend login/registration form code is running on localhost:3000.

My question is would it be easier to put both my frontend and backend code into one file structure so I don't have to send the data from my form to my backend running on another domain so for example both my Node.js and React.js code would be running on localhost:3000 and would just send the form information to the Node.js files that validate the user credentials instead of having to use a fetch method to send my form data to the backend. Is this even possible?

CodePudding user response:

Yes, it is possible, you can use Express to serve your static files (frontend ReactJS) and also your backend routes. Take the following Github repository as an example.

https://github.com/Bikranshu/express-react-boilerplate

CodePudding user response:

That is possible, A monolithic architecture with express and reactjs (https://medium.com/@sesitamakloe/easy-express-react-monolith-chapter-1-a1567c6ff483)

  •  Tags:  
  • Related