I have developed a ReactJS app using the create-react-app on my local windows 10 machine..
Now, I want to deploy this application on a on-premise windows 2008 R2 server. I do not have much experience with this. When I searched over the internet, all the articles are talking about either deploying into IIS or in cloud. But, I do not want to use IIS and I have On-Premise server.
Is there any other way to deploy and host this ReactJS application on Windows server machine? Maybe just using the Node.JS?
Create the build using npm run build and write a nodejs script with express to serve the build directory.
The nodejs script would be like this:
start-server.js
const express = require("express");
const path = require("path");
const basePath = '';
const app = express();
app.use(basePath + "/", express.static(path.resolve(__dirname + "/build")));
app.get("*", (request, response) => {
response.sendFile(path.resolve(__dirname + "/build/index.html"));
});
app.listen(port);
To start the server:
node start-server.js