score:1
Accepted answer
first create build folder in react side by running
npm run build
then add these lines of code in the node side in app.js/index.js
app.use(express.static("<your_react_app_folder>/build"));
if (process.env.node_env === "production") {
const path = require("path");
app.get("/*", (req, res) => {
res.sendfile(path, resolve(__dirname, "../<your_react_app_folder>", "build", "index.html"));
});
}
then deploy it to heroku/remote server.
note: remember to remove /build line from .gitignore file
Source: stackoverflow.com
Related Query
- How do I deploy ReactJs + Node app onto remote server?
- Not Sure How to Start and Deploy ReactJS App on Production Server with ExpressJS
- How to deploy a React App on Apache web server
- React tutorial - how do I start the node server for a reactJs application?
- how to deploy reactJS application on Tomcat Server
- How can I start my node server and react app at the same time?
- How to deploy React App on production with Server Side Rendering
- How to display IP camera feed from an RTSP url onto reactjs app page?
- How to pass data in server side rendering to reactjs component from node
- How to deploy ReactJS web application on a windows server using Node.JS?
- How to deploy reactJS app with json-server
- How to deploy react app in ubuntu server with bitbucket pipeline
- How to deploy a react app that does not have index.html on an apache server for production
- How to properly deploy ReactJS app as Azure web app
- How to deploy Strapi backend and ReactJS frontend to a single Heroku app
- How to deploy and host react app on Apache server
- How to setup multistage builds for a ReactJS App with server side rendering
- How to push and deploy Reactjs app to gh-pages
- How can I make my front end app access my node server apis
- How to deploy a ReactJS app built using Create-react-app on Linux?
- how to load latest version of ReactJS app from server
- how to deploy next js app without vercel to custom server using ftp server like filezilla
- Cannot deploy React app at Node JS server
- How to deploy my ReactJS web application to Production Server
- How to deploy node js app with react to heroku
- How to deploy a demo app for a ReactJS component library on netlify?
- How to start node server when React app starts in production
- how to redirect websocket request through node js from reactjs to java server
- How to GET data from a remote server using Node
- How to fetch data only once in a Next.js app and make it accesible to all the app, both in server and client
More Query from same tag
- React: Access ref passed between components via render props
- sort and render list contact by first letter alphabet
- Can someone explain how this state update is resolved?
- Cypress hooks in grouped describe
- NextJS/React ignore parent component
- How to display specific img on li hover without get request in react?
- Why is my React component icon coming out as a typeof object?
- How to open a page with react-router-dom without any event?
- How to fetch the new data in response to React Router change with Redux?
- Can't use dispatch inside useEffect() with redux
- Having trouble removing data from firebase - React, Javascript, Firebase
- iOS 11 browsers image bug
- How to access variable inside a for-in loop within an async function (javascript/react)?
- assert that only single child is passed in `this.props.children`
- Cannot read property 'paginationOption' of undefined in React Bootstrap Typeahead
- Detect which word is clicked within a paragraph in React
- react hooks: Can't create list with map function
- Differentiate between single and double click in React
- Will JSX conditional rendering out of an object code split?
- Type 'string' has no properties in common with type 'Properties<ReactText, string & {}>
- How to align item to center using Ant Design PageHeader?
- TypeError: undefined is not an object (evaluating 'this.setState')
- How do I set background color of color picker from API call?
- Comparing two arrays and finding difference
- How to get a variable back from a called component
- How to save my input values to text file with ReactJS?
- Rendering a Google Map without react-google-map
- Redirecting a user to a different path in React
- How to pass state as a redux action
- React js, pass a function with parameters as props without using this keyword