/opt/canhelp/node_modules/next/dist/server/lib/router-utils
NameSizeModeActions
block-cross-site.d.ts2770644editdlrm
block-cross-site.js32420644editdlrm
block-cross-site.js.map52200644editdlrm
build-data-route.d.ts2360644editdlrm
build-data-route.js19010644editdlrm
build-data-route.js.map26760644editdlrm
build-prefetch-segment-data-route.d.ts7880644editdlrm
build-prefetch-segment-data-route.js26130644editdlrm
build-prefetch-segment-data-route.js.map37020644editdlrm
decode-path-params.d.ts3450644editdlrm
decode-path-params.js14810644editdlrm
decode-path-params.js.map15700644editdlrm
filesystem.d.ts27200644editdlrm
filesystem.js271530644editdlrm
filesystem.js.map376760644editdlrm
instrumentation-globals.external.d.ts5040644editdlrm
instrumentation-globals.external.js36020644editdlrm
instrumentation-globals.external.js.map47580644editdlrm
instrumentation-node-extensions.d.ts1940644editdlrm
instrumentation-node-extensions.js50300644editdlrm
instrumentation-node-extensions.js.map71780644editdlrm
is-postpone.d.ts570644editdlrm
is-postpone.js4360644editdlrm
is-postpone.js.map5970644editdlrm
proxy-request.d.ts3700644editdlrm
proxy-request.js42890644editdlrm
proxy-request.js.map65810644editdlrm
resolve-routes.d.ts11250644editdlrm
resolve-routes.js338990644editdlrm
resolve-routes.js.map471420644editdlrm
route-types-utils.d.ts24280644editdlrm
route-types-utils.js113940644editdlrm
route-types-utils.js.map192130644editdlrm
router-server-context.d.ts11290644editdlrm
router-server-context.js6890644editdlrm
router-server-context.js.map22830644editdlrm
setup-dev-bundler.d.ts27220644editdlrm
setup-dev-bundler.js473040644editdlrm
setup-dev-bundler.js.map681600644editdlrm
typegen.d.ts3370644editdlrm
typegen.js247410644editdlrm
typegen.js.map347410644editdlrm
types.d.ts1810644editdlrm
types.js1150644editdlrm
types.js.map670644editdlrm
Edit: /opt/canhelp/node_modules/next/dist/server/lib/router-utils/block-cross-site.js (3242B)
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "blockCrossSite", { enumerable: true, get: function() { return blockCrossSite; } }); const _url = require("../../../lib/url"); const _log = require("../../../build/output/log"); const _csrfprotection = require("../../app-render/csrf-protection"); function warnOrBlockRequest(res, origin, mode) { const originString = origin ? `from ${origin}` : ''; if (mode === 'warn') { (0, _log.warnOnce)(`Cross origin request detected ${originString} to /_next/* resource. In a future major version of Next.js, you will need to explicitly configure "allowedDevOrigins" in next.config to allow this.\nRead more: https://nextjs.org/docs/app/api-reference/config/next-config-js/allowedDevOrigins`); return false; } (0, _log.warnOnce)(`Blocked cross-origin request ${originString} to /_next/* resource. To allow this, configure "allowedDevOrigins" in next.config\nRead more: https://nextjs.org/docs/app/api-reference/config/next-config-js/allowedDevOrigins`); if ('statusCode' in res) { res.statusCode = 403; } res.end('Unauthorized'); return true; } function isInternalDevEndpoint(req) { if (!req.url) return false; try { // TODO: We should standardize on a single prefix for this const isMiddlewareRequest = req.url.includes('/__nextjs'); const isInternalAsset = req.url.includes('/_next'); // Static media requests are excluded, as they might be loaded via CSS and would fail // CORS checks. const isIgnoredRequest = req.url.includes('/_next/image') || req.url.includes('/_next/static/media'); return !isIgnoredRequest && (isInternalAsset || isMiddlewareRequest); } catch (err) { return false; } } const blockCrossSite = (req, res, allowedDevOrigins, hostname)=>{ // in the future, these will be blocked by default when allowed origins aren't configured. // for now, we warn when allowed origins aren't configured const mode = typeof allowedDevOrigins === 'undefined' ? 'warn' : 'block'; const allowedOrigins = [ '*.localhost', 'localhost', ...allowedDevOrigins || [] ]; if (hostname) { allowedOrigins.push(hostname); } // only process internal URLs/middleware if (!isInternalDevEndpoint(req)) { return false; } // block non-cors request from cross-site e.g. script tag on // different host if (req.headers['sec-fetch-mode'] === 'no-cors' && req.headers['sec-fetch-site'] === 'cross-site') { return warnOrBlockRequest(res, undefined, mode); } // ensure websocket requests from allowed origin const rawOrigin = req.headers['origin']; if (rawOrigin) { const parsedOrigin = (0, _url.parseUrl)(rawOrigin); if (parsedOrigin) { const originLowerCase = parsedOrigin.hostname.toLowerCase(); if (!(0, _csrfprotection.isCsrfOriginAllowed)(originLowerCase, allowedOrigins)) { return warnOrBlockRequest(res, originLowerCase, mode); } } } return false; }; //# sourceMappingURL=block-cross-site.js.map