Answer the question
In order to leave comments, you need to log in
How to do multiple page processing?
Suppose I want to make a site on express.js, there will be several pages: home (/), news (/news/:articleid), contacts (/contacts), whatever else. What is the best way to organize this so that express always gives the same html file, and at the front js works like this:
const url = /* парсим url */
switch (url) {
case '/':
/* рендерим главную страницу */
case '/news':
/* ... */
}
Answer the question
In order to leave comments, you need to log in
You can just do something like
app.get('/|', function(request, response){
console.log('/');
response.sendFile(__dirname + "/build/index.html");
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question