Actually I am using node js to implement SSR in my app.In server side rendering, html is prepared inside the server dynamically and updated.I want to update my html root element in the server using a js file but before sending it to the client. but when i tried it the js file is executing in the client. i want to execute it in the server and then append child to the html and then send that html file. Anyone help if it a wrong method and if not how can i do it
//my app.js
const express = require('express');
const app = express();
const path= require('path');
const cors = require('cors');
// const {sourceHTML} =require('./middlewares/fileHandler');
//for rendering css through the server we use app.use()
app.use(express.static(__dirname));
app.use(cors());
app.listen(3000,()=>{
console.log("application started and running on port 3000")
});
app.get("/",(req,res)=>{
res.status(200).sendFile(__dirname+'/html/home.html')
})
my home.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>home</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
so basically i want to edit html file from a js file so to access that html i have to use script tag inside html but problem happens that the script tag is parsed to the client so actually i want to execute that script at the server side before sending.