#Images not loading in handlebar template

1 messages · Page 1 of 1 (latest)

proper socket
#

I implemented mail templates using handlebar. Everything is working correctly, mails are sent - template and dynamic content is rendered but my images are not loading. I stored my images in static/images folder in root file and added static file setup:

ServeStaticModule.forRoot({
  rootPath: join(__dirname, '..', 'static')
})

and used image in template as:

src="images/logo.svg"

I can access image through http://localhost:3000/images/logo.svg so serving static files works correctly.
What am I missing?

fossil dagger
#

You have to use absolute paths in your email messages. In this case src="http://localhost:3000/images/logo.svg", which is not exactly going to work for anyone else than you 😁

bright spade
#

So in this case the safest approach is to have public images in a CDN or similar, and use them instead of nest statically serving the images?