Lysander Mealy
Lysander Mealy

Reputation: 133

Express.js - I can't set the Content-Type

I am using Express.js, and I can't set the Content-Type header for some reason. I set it to text/html and it sends with application/octet-stream anyway. Here is my code:

const express = require("express")
const app = express()

const fs = require("fs")

const Template = require("./Template")

app.get("/", (req, res) => {
    res.type("html")
    res.send(String(Template.solidify(fs.readFileSync("index.html"))))
})

app.listen(80, () => {
    console.log("Listening...")
})

Template.solidify() just returns what it's given for now. index.html is an empty html file (with head, body, etc.).

Upvotes: 0

Views: 272

Answers (1)

Lysander Mealy
Lysander Mealy

Reputation: 133

Update for anybody looking for answers, I just had to clear my browser cache.

I use chrome, and I was able to disable cache while devtools is open by checking the box.

Upvotes: 1

Related Questions