Express Not Rendering HTML Properly

For some reason express isn’t rendering my file properly. I’m using Bootstrap studio for the design of the page that I haven’t completed yet, so I’m using a default template for the time being. Instead of appearing as it should like this:image
It ends up appearing like this.

This is the line of code that’s rendering it.

resp.sendFile("index.html", {root: path.join(__dirname, "")})


If there’s a more efficient way of going about this or fixing it any help would be appreciated, thanks!

I don’t think this has anything to do with express. Instead, some of your files are going to localhost and you also need to put them in a public folder like on hello-express or handle them (e.g. With res.sendFile) in your server file. Can you send both the backend and html code in full?

1 Like

Put all your Files to public Folder,

Then, In your server.js:

//const express = require("express");

//add this 
1 Like

You might want to try putting type="text/css" into the link tag where you reference the bootstrap link? These are very odd errors.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.