Commit f5edfebc authored by Alexey Boklin's avatar Alexey Boklin Committed by Luis Fernando Alvarez D

Docs: Fix comments in with-sentry example (server.js) (#8125)

parent 68e3223c
...@@ -27,7 +27,7 @@ function sessionCookie (req, res, next) { ...@@ -27,7 +27,7 @@ function sessionCookie (req, res, next) {
} }
const sourcemapsForSentryOnly = token => (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) { if (!dev && !!token && req.headers['x-sentry-token'] !== token) {
res res
.status(401) .status(401)
...@@ -38,19 +38,18 @@ const sourcemapsForSentryOnly = token => (req, res, next) => { ...@@ -38,19 +38,18 @@ const sourcemapsForSentryOnly = token => (req, res, next) => {
} }
app.prepare().then(() => { app.prepare().then(() => {
// The app.buildId is only available after app.prepare(), hence why we setup // app.buildId is only available after app.prepare(), hence why we setup here
// here.
const { Sentry } = require('./utils/sentry')(app.buildId) const { Sentry } = require('./utils/sentry')(app.buildId)
express() express()
// This attaches request information to sentry errors // This attaches request information to Sentry errors
.use(Sentry.Handlers.requestHandler()) .use(Sentry.Handlers.requestHandler())
.use(cookieParser()) .use(cookieParser())
.use(sessionCookie) .use(sessionCookie)
.get(/\.map$/, sourcemapsForSentryOnly(process.env.SENTRY_TOKEN)) .get(/\.map$/, sourcemapsForSentryOnly(process.env.SENTRY_TOKEN))
// Regular next.js request handler // Regular next.js request handler
.use(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()) .use(Sentry.Handlers.errorHandler())
.listen(port, err => { .listen(port, err => {
if (err) { if (err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment