MCPcopy Index your code
hub / github.com/github/docs / helmetMiddleware

Function helmetMiddleware

middleware/helmet.js:69–92  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

67const staticDeprecatedHelmet = helmet(STATIC_DEPRECATED_OPTIONS)
68
69export default function helmetMiddleware(req, res, next) {
70 // Enable CORS
71 if (['GET', 'OPTIONS'].includes(req.method)) {
72 res.set('access-control-allow-origin', '*')
73 }
74
75 // Determine version for exceptions
76 const { requestedVersion } = isArchivedVersion(req)
77
78 // Exception for deprecated Enterprise docs (Node.js era)
79 if (
80 versionSatisfiesRange(requestedVersion, '<=2.19') &&
81 versionSatisfiesRange(requestedVersion, '>2.12')
82 ) {
83 return nodeDeprecatedHelmet(req, res, next)
84 }
85
86 // Exception for search in deprecated Enterprise docs <=2.12 (static site era)
87 if (versionSatisfiesRange(requestedVersion, '<=2.12')) {
88 return staticDeprecatedHelmet(req, res, next)
89 }
90
91 return defaultHelmet(req, res, next)
92}

Callers

nothing calls this directly

Calls 2

isArchivedVersionFunction · 0.85
versionSatisfiesRangeFunction · 0.85

Tested by

no test coverage detected