Skip to content
Merged
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
9 changes: 4 additions & 5 deletions examples/with-sentry/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function sessionCookie (req, res, next) {
}

const sourcemapsForSentryOnly = token => (req, res, next) => {
// In production we only want to serve source maps for sentry
// In production we only want to serve source maps for Sentry
if (!dev && !!token && req.headers['x-sentry-token'] !== token) {
res
.status(401)
Expand All @@ -38,19 +38,18 @@ const sourcemapsForSentryOnly = token => (req, res, next) => {
}

app.prepare().then(() => {
// The app.buildId is only available after app.prepare(), hence why we setup
// here.
// app.buildId is only available after app.prepare(), hence why we setup here
const { Sentry } = require('./utils/sentry')(app.buildId)

express()
// This attaches request information to sentry errors
// This attaches request information to Sentry errors
.use(Sentry.Handlers.requestHandler())
.use(cookieParser())
.use(sessionCookie)
.get(/\.map$/, sourcemapsForSentryOnly(process.env.SENTRY_TOKEN))
// Regular next.js request handler
.use(handler)
// This handles errors if they are thrown before raching the app
// This handles errors if they are thrown before reaching the app
.use(Sentry.Handlers.errorHandler())
.listen(port, err => {
if (err) {
Expand Down