fastboot-express-middleware icon indicating copy to clipboard operation
fastboot-express-middleware copied to clipboard

Add Content-Type: text/html; charset-utf8

Open mhluska opened this issue 7 years ago • 3 comments

This is lightly tested on my local machine. I think we need to add this because the initial FastBoot request is missing a content-type header. See my issue here: https://github.com/ember-fastboot/fastboot-app-server/issues/78

This is important because some Node-based crawlers simply break without a content-type header. Also Twitterbot doesn't seem to be able to get meta tags when this header is not present.

mhluska avatar Mar 28 '18 00:03 mhluska

I had a user report to me that Safari just downloads the HTML file immediately and I believe this is because my site has the X-Content-Type-Options header set to nosniff. 😞

jimsynz avatar Jun 08 '18 02:06 jimsynz

I've realized this is only needed in the chunkedResponse case. I've updated the PR.

mhluska avatar Oct 10 '18 06:10 mhluska

Note: I still had to add this in fastboot-app-server to get things working in production 🤷‍♂️ :

// HACK: When using `chunkedResponse` we have to explicitly set the content
// type otherwise the header is missing.
app.use(function(req, res, next) {
  if (!req.url.includes('.')) {
    res.type('html');
  }
  next();
});

mhluska avatar Oct 10 '18 09:10 mhluska