Problem loading static files on routes with nodeJS / expressJS

0

Programming my first system I came across a little problem ... I'm creating a client system and changed the structure of the views folder as follows:

  • / app
    • / views
      • / clients
        • clients.ejs
        • add.ejs
      • / users
        • users.ejs
        • add.ejs

So far, all right, routes, controllers and models. But when I click the button with the "/ clients / add" route that leads to "/clients/add.js" it loads the page ok, but the static paths are changed, trying to search "/ clients / css" or " / clients / img "where the right would be" / css "and" / img ".

How do I resolve this problem with multiple pages in views?

/app/routes/clientes.js

module.exports = function(application){

    application.get('/clientes', function(req, res){
        application.app.controllers.clientes.cadastrar(application, req, res);
    });

    application.get('/clientes/adicionar', function(req, res){
        application.app.controllers.clientes.adicionar(application, req, res);
    });

}

/app/controllers/clients.js

module.exports.clientes = function (application, req, res){
    res.render('clientes/clientes', {validacao: {}, dadosForm: {}});
}

module.exports.adicionar = function(application, req, res){
    res.render('./clientes/adicionar');
}

module.exports.cadastrar = function(application, req, res){
    res.send('tudo ok');
}

in server.js the static express configuration

app.use(express.static('./app/public'));
    
asked by anonymous 03.03.2017 / 18:21

1 answer

0

    
06.03.2017 / 14:08