Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
¿Cómo agregar el enrutador vue con srr?

Estoy creando mi proyecto en vue y vite js para ssr. Hasta ahora, la representación del lado del servidor funciona bien, como si pudiera agregar un enrutador vue a mi proyecto pero representar el contenido. He intentado importar las rutas y hacer una app.use (routes) Pero no representa el contenido de las rutas, solo la app.vue

Mi main.js

 const { createServer } = require("vite"); const server = require("express")(); const fs = require("fs"); const path = require("path"); async function main() { const vite = await createServer({ server: { middlewareMode: true } }); server.use(vite.middlewares); server.get("*", async (req, res) => { let html = fs.readFileSync(path.resolve(__dirname, "index.html"), "utf-8"); const { render } = await vite.ssrLoadModule("/src/entry-server.js"); const appContent = await render(); html = html.replace("<!--ssr-->", appContent); res.end(html); }); server.listen(8080); } main();

Mi servidor de entrada.js

 import { createApp } from "vue"; import { renderToString } from "@vue/server-renderer"; import App from "./App.vue"; export async function render() { const app = createApp(App); const appContent = await renderToString(app); return appContent; }

Mi entrada-cliente.js

 import { createApp } from "vue"; import App from "./App.vue"; const app = createApp(App); app.mount("#app");
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!