A
A
Alexander Koshelev2018-09-30 16:31:39
Browsers
Alexander Koshelev, 2018-09-30 16:31:39

Why are styles not included for dynamic node.js pages?

Good afternoon guys, I have such a problem that I can’t connect styles to dynamic pages, writes 404 css.

router.get('/user/:id?', async (req, res, next) => {
  const getProfile = req.params.id;
  const dataProfile = await User.findOne({
    where: {
      username: getProfile
    }
  });
  console.log(dataProfile);
  res.render('user', {getProfile });
});

I want usernames /user/username to be assigned to the USER page and the same page style everywhere, it turns out in this code with a user/:id request (there is a transition to these pages from the main page) I take the id parameters and take from database of the desired user, and I want the USER page to be rendered with its own styles and info from the database is added to it and the url is changed by adding its id from the database after /user so that in the end at /user/7, let's say the USER page is visualized with its own styles
Help please who knows

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bqio, 2018-09-30
@Xandr24

Change "./public" to "../public" in the path of the CSS file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question