With a Node, Express, and MongoDB enabled server now running, we can extend it to serve an HTML template in response to an incoming request at the root URL /.
In the template.js file, add a JS function that returns a simple HTML document that will render Hello World on the browser screen.
mern-skeleton/template.js:
export default () => { return `<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>MERN Skeleton</title> </head> <body> <div id="root">Hello World</div> </body> </html>`}
To serve this template at the root URL, update the express.js file to import this template, and send it in the response to a GET request for the '/' route.
mern-skeleton/server/express.js:
import Template ...