@@ -13,7 +13,6 @@ children:
|
||||
- /about-enterprise-accounts
|
||||
- /managing-your-github-enterprise-license
|
||||
- /managing-billing-for-your-enterprise
|
||||
- /about-upgrades-to-new-releases
|
||||
- /system-overview
|
||||
- /about-the-github-enterprise-api
|
||||
---
|
||||
|
||||
15
middleware/catch-bad-accept-language.js
Normal file
15
middleware/catch-bad-accept-language.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const accept = require('@hapi/accept')
|
||||
|
||||
// Next.JS uses the @hapi/accept package to parse and detect languages. If the accept-language header is malformed
|
||||
// it throws an error from within Next.JS, which results in a 500 response. This ends up being noisy because we
|
||||
// track 500s. To counteract this, we'll try to catch the error first and make sure it doesn't happen
|
||||
module.exports = function catchBadAcceptLanguage (req, res, next) {
|
||||
try {
|
||||
accept.language(req.headers['accept-language'])
|
||||
} catch (e) {
|
||||
// if there's a problem with parsing 'accept-language', just clear it out.
|
||||
req.headers['accept-language'] = ''
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
||||
@@ -54,6 +54,7 @@ module.exports = function (app) {
|
||||
app.use(require('compression')())
|
||||
app.use(require('./disable-caching-on-safari'))
|
||||
app.use(require('./set-fastly-surrogate-key'))
|
||||
app.use(require('./catch-bad-accept-language'))
|
||||
|
||||
// *** Config and context for redirects ***
|
||||
app.use(require('./req-utils')) // Must come before record-redirect and events
|
||||
|
||||
1
package-lock.json
generated
1
package-lock.json
generated
@@ -7,6 +7,7 @@
|
||||
"name": "docs.github.com",
|
||||
"license": "(MIT AND CC-BY-4.0)",
|
||||
"dependencies": {
|
||||
"@hapi/accept": "^5.0.2",
|
||||
"@primer/components": "^28.0.4",
|
||||
"@primer/css": "^16.2.0",
|
||||
"@primer/octicons": "^14.1.0",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
".next/cache"
|
||||
],
|
||||
"dependencies": {
|
||||
"@hapi/accept": "^5.0.2",
|
||||
"@primer/components": "^28.0.4",
|
||||
"@primer/css": "^16.2.0",
|
||||
"@primer/octicons": "^14.1.0",
|
||||
|
||||
Reference in New Issue
Block a user