0

I have routes something like this

router.get('/home',controller.home)
router.get('/',controller.home)
router.get('/view/:Id/', controller.view);

Images are placed in public/img. I have used this code in index.js

app.use(express.static(__dirname + '/public'));

The problem is that from home.ejs, I can access the images by using

<img src="img/img1.png">

But from view.ejs, I cannot access the images using<img src="img/img1.png"> When i open view.ejs in my browser, the img source is changed to <img src=localhost:3000/view/1/img/img1.png> and is not displayed.

Ujwal
  • 73
  • 1
  • 12

0 Answers0