Este es mi código Express usando manubrios usando el código .hbs
const express = require("express"); const path = require("path"); const app = express(); const port = 3001; //for mongo all mongodata require("dotenv").config(); const cors = require("cors"); app.use(cors()); const Handle = require("./views/mongoschema"); const staticPath= path.join(__dirname, "./views"); app.set("view engine","hbs"); app.use(express.static(staticPath)); //for maintaining the format app.use(express.json()); //to GET the data in the from the form app.use(express.urlencoded({extended:false})); //to render the page this is coming (1st) app.get("/",(req, res) => { res.render('index'); }); //for login validation app.post("/mongoschema",async(req, res) => { try { const handleData = new Handle({ title: req.body.one, description: req.body.two, url: req.body.four }) const handled = await handleData.save(); //After REGISTRATION sending the user to index file ***res.status(201).render("index");*** } catch (error) { res.status(400).send(error); } }); app.get("/pages", (req, res) => { Handle.find({}) .then((items) => res.json(items)) .catch((err) => console.log(err)); }); app.listen(port, () => { console.log('listening to the port ${port)'); });el archivo que quiero ejecutar ahora es un "archivo.js" y el índice es "index.hbs" no puede procesar el "archivo.js" ¿cómo puedo procesarlo o seré redirigido al "archivo.js"? archivo Después de que mi inicio de sesión sea EXITOSO.
Como alguien mencionó en los comentarios, deberías estar usando:
res.redirect("/"); // path to route as parameter - in this case, index.