Answer the question
In order to leave comments, you need to log in
What is the best way to set paths to static files in Node?
For example, I have routes in my project:
- project/
- - routers/
- - - regRouter.js
regRouter.js has a page rendering handler:
router.get('/', function (req, res) {
res.render('/home/nodejs/project/public/views/reg');
});
Answer the question
In order to leave comments, you need to log in
What people don’t go to just not to read the documentation
https://expressjs.com/en/4x/api.html#res.render
The view argument is a string that is the file path of the view file to render. This can be an absolute path, or a path relative to the views setting.
views
String or Array
A directory or an array of directories for the application's views. If an array, the views are looked up in the order they occur in the array.
default value: process.cwd() + '/views'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question