MCPcopy Create free account
hub / github.com/github/docs / handleInvalidPaths

Function handleInvalidPaths

middleware/handle-invalid-paths.js:5–13  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

3const STATSD_KEY = 'middleware.handle_invalid_paths'
4
5export default function handleInvalidPaths(req, res, next) {
6 // Prevent various malicious injection attacks targeting Next.js
7 if (req.path.match(/^\/_next[^/]/) || req.path === '/_next/data' || req.path === '/_next/data/') {
8 statsd.increment(STATSD_KEY, 1, ['check:nextjs-injection-attack'])
9 return next(404)
10 }
11
12 return next()
13}

Callers

nothing calls this directly

Calls 1

nextFunction · 0.50

Tested by

no test coverage detected