HOW LOAD IMAGES ON NODE.JS WEBSITE (WHICH IS HOSTED ON HEROKU)?

26 June 2021, Abdulhakim

When you put some images on your codebase and you see your code running, text displaying but images not, then this might because of not refering in correct way to your images. To use images (and also stylesheets), you need to put them inside a static folder. Simple steps:

1) create a folder on the main dir of your codebase and name it anything (we can name it "static").
2) then place your images inside.
3) then go to your main node.js file (You should name it as "app.js" or "server.js") and copy paste as the highlighted area to your file.

this is a article image

4) Then go to any ejs or html file you are using and refer to your image like this

this is a article image