Fix for Markdown rendering for SSR

There’s a problem with ngx-markdown package – it doesn’t work out of the box with server side rendering, because the loader uses HttpClient to load the markdown from a file, but on the server side the relative path makes no sense (as there’s no base URL), so it actually fails to render on the server. Here’s the fix:

We provide a custom loader on the server side in app.server.module.ts:

This loader just reads the file with readFileSync on the server. Problem solved!


Published by Andrew Leschinsky

Founder and tech lead.