0

I can not figure out what is the relation between the route path and the assets folder which contain css style and images.

here is an example for what happening with me:

  • Whenever i set the route path to be like this

'/something/something'

in a get function and render X-page for example as response, the X-page uses the css and images which exist in the assets folder.

  • But when the route path become more than that like

'/something/something/something/something'

and render the same X-page, It doesn't use the assets folder.

I am using this line to serve the static files :

app.use('/assets', express.static('assets'));

And my files structure :

enter image description here

may anyone explain what is going on ?

Khalifa Gad
  • 361
  • 1
  • 6
  • 26
  • Please check this https://stackoverflow.com/questions/10434001/static-files-with-express-js – Parth Raval Jun 24 '18 at 13:22
  • according to this post my syntax and logic is right, but i don't know that happen in the core – Khalifa Gad Jun 24 '18 at 14:01
  • just you need to move your views in public folder which is static file for serving `ejs` & `html` `app.use('/assets', express.static('assets'));` will solve your issue. – Parth Raval Jun 25 '18 at 04:43

0 Answers0