Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo sync #7382

Merged
merged 4 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion content/admin/overview/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
Expand Down
15 changes: 15 additions & 0 deletions middleware/catch-bad-accept-language.js
Original file line number Diff line number Diff line change
@@ -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()
}
1 change: 1 addition & 0 deletions middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down