{"action":"created","issue":{"url":"https://api.github.com/repos/cbas/express-history-api-fallback/issues/5","repository_url":"https://api.github.com/repos/cbas/express-history-api-fallback","labels_url":"https://api.github.com/repos/cbas/express-history-api-fallback/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/cbas/express-history-api-fallback/issues/5/comments","events_url":"https://api.github.com/repos/cbas/express-history-api-fallback/issues/5/events","html_url":"https://github.com/cbas/express-history-api-fallback/issues/5","id":190498545,"number":5,"title":"Ignore .js files","user":{"login":"Mosho1","id":5153007,"avatar_url":"https://avatars.githubusercontent.com/u/5153007?v=3","gravatar_id":"","url":"https://api.github.com/users/Mosho1","html_url":"https://github.com/Mosho1","followers_url":"https://api.github.com/users/Mosho1/followers","following_url":"https://api.github.com/users/Mosho1/following{/other_user}","gists_url":"https://api.github.com/users/Mosho1/gists{/gist_id}","starred_url":"https://api.github.com/users/Mosho1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mosho1/subscriptions","organizations_url":"https://api.github.com/users/Mosho1/orgs","repos_url":"https://api.github.com/users/Mosho1/repos","events_url":"https://api.github.com/users/Mosho1/events{/privacy}","received_events_url":"https://api.github.com/users/Mosho1/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-19T14:16:12Z","updated_at":"2016-11-19T16:05:24Z","closed_at":"2016-11-19T16:05:24Z","body":"I would like requests for non-existing `.js` (or `.css`, etc.) files will result in a 404. Is there a way to do that?"},"comment":{"url":"https://api.github.com/repos/cbas/express-history-api-fallback/issues/comments/261722326","html_url":"https://github.com/cbas/express-history-api-fallback/issues/5#issuecomment-261722326","issue_url":"https://api.github.com/repos/cbas/express-history-api-fallback/issues/5","id":261722326,"user":{"login":"cbas","id":78718,"avatar_url":"https://avatars.githubusercontent.com/u/78718?v=3","gravatar_id":"","url":"https://api.github.com/users/cbas","html_url":"https://github.com/cbas","followers_url":"https://api.github.com/users/cbas/followers","following_url":"https://api.github.com/users/cbas/following{/other_user}","gists_url":"https://api.github.com/users/cbas/gists{/gist_id}","starred_url":"https://api.github.com/users/cbas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbas/subscriptions","organizations_url":"https://api.github.com/users/cbas/orgs","repos_url":"https://api.github.com/users/cbas/repos","events_url":"https://api.github.com/users/cbas/events{/privacy}","received_events_url":"https://api.github.com/users/cbas/received_events","type":"User","site_admin":false},"created_at":"2016-11-19T16:05:24Z","updated_at":"2016-11-19T16:05:24Z","body":"Probably makes sense to handle that logic in a separate middleware. Not part of the scope of the fallback middleware.\r\n\r\nOff the top of my head, you could do something like:\r\n\r\n`blockExtensions.js`\r\n```js\r\nimport {extname} from 'path'\r\nimport {NotFound} from 'http-errors'\r\n\r\nexport default (...extensions) => (req, res, next) => {\r\n  const extension = extname(req.path)\r\n  if (extension && !extensions.includes(extension)) next(new NotFound())\r\n  else next()\r\n}\r\n```\r\n\r\n```js\r\nimport blockExtensions from './blockExtensions'\r\n\r\n// ... handle normal requests ... then put the fallbacks at the end:\r\n\r\napp.use(blockExtensions(['js', 'css'])\r\napp.use(fallback(__dirname + '/index.html'))\r\n```"}}
{"actor":{"display_login":"cbas"}}