Skip to content

Commit 75a43f5

Browse files
timneutkensarunoda
authored andcommitted
Make sure we do not expose stacktraces in production (vercel#2843)
1 parent 26c5d90 commit 75a43f5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

server/render.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ export async function renderScript (req, res, page, opts) {
138138
}
139139
}
140140

141-
export async function renderScriptError (req, res, page, error, customFields, opts) {
141+
export async function renderScriptError (req, res, page, error, customFields, { dev }) {
142142
// Asks CDNs and others to not to cache the errored page
143143
res.setHeader('Cache-Control', 'no-store, must-revalidate')
144144
// prevent XSS attacks by filtering the page before printing it.
145145
page = xssFilters.uriInSingleQuotedAttr(page)
146+
res.setHeader('Content-Type', 'text/javascript')
146147

147148
if (error.code === 'ENOENT') {
148-
res.setHeader('Content-Type', 'text/javascript')
149149
res.end(`
150150
window.__NEXT_REGISTER_PAGE('${page}', function() {
151151
var error = new Error('Page does not exist: ${page}')
@@ -157,9 +157,8 @@ export async function renderScriptError (req, res, page, error, customFields, op
157157
return
158158
}
159159

160-
res.setHeader('Content-Type', 'text/javascript')
161160
const errorJson = {
162-
...errorToJSON(error),
161+
...serializeError(dev, error),
163162
...customFields
164163
}
165164

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy