fastboot-app-server icon indicating copy to clipboard operation
fastboot-app-server copied to clipboard

Missing Content-Type header

Open mhluska opened this issue 7 years ago • 3 comments

The initial response for the html page is missing Content-Type: text/html; charset=utf-8.

I think the reason this is happening is express-http-server.js has the following code:

 52     if (this.distPath) {
 53       app.get('/', fastbootMiddleware);
 54       app.use(express.static(this.distPath));
 55       app.get('/assets/*', function(req, res) {
 56         res.sendStatus(404);
 57       });
 58     }

app.get('/', fastbootMiddleware); causes the initial request to not have the correct content-type since that is normally handled by express.static.

So it seems fastboot-express-middleware needs to call .type('text/html') somewhere.

mhluska avatar Mar 27 '18 23:03 mhluska

I just have been running into exactly this issue and noticed that it only shows up when using chunkedResponse: true. Looks like using chunkedResponse: false seems to work as a workaround. Unfortunately the readme has chunkedResponse: true within its example, so most people starting to integrate FastBoot will likely hit this issue at some point.

st-h avatar Apr 19 '19 12:04 st-h

I was having trouble getting some twitter cards to work, and noticed this message at the bottom: https://github.com/ember-fastboot/fastboot-app-server#scraper-issues

As of 2019-06-06, Twitter and LinkedIn's scrapers have a hard time extracting your site's metadata for sharing if chunkedResponse is set to true in your server.js file. Set chunkedResponse: false if your meta tags are in place but the Twitter card validator shows "Card not found" or LinkedIn's Post Inspector shows a 500 error.

But I actually posted in the twitter dev forum before seeing this, and got a response that it was because I'm missing a content-type header. https://twittercommunity.com/t/warn-no-metatags-found-even-though-they-are-there/127287

So maybe the issue is not the chunkedResponse but the missing content-type header? 🤔

mcfiredrill avatar Jul 23 '19 01:07 mcfiredrill