Skip to content

Commit

Permalink
Improve HTML Detection in History Support Middleware
Browse files Browse the repository at this point in the history
Use built in ExpressJS methods for detecting HTML in the Accept header.
  • Loading branch information
James Herdman committed Jul 2, 2014
1 parent cffb385 commit c720399
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tasks/server/middleware/history-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var path = require('path');

module.exports = function() {
return function(req, res, next) {
var hasHTMLHeader = (req.headers.accept || []).indexOf('text/html') === 0;
var hasHTMLHeader = req.accepts('html') === 'html';
var hasNoFileExtension = path.extname(req.path) === '';
var isForTests = /^\/tests/.test(req.path);

Expand Down

2 comments on commit c720399

@simonexmachina
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the --proxy feature. req.accepts('html') returns true for */*, so my API requests no longer go through the proxy. The XHR requests to my api don't specify text/html, so previously they would go through the proxy to the API.

@simonexmachina
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #1263

Please sign in to comment.