Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
Append child to html before sending to the client in SSR App

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.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda