{"record":{"id":"5e949eaa6a62edb1","repo":"denoland/deno","slug":"request-mode-navigate-is-not-allowed","errorCode":null,"errorMessage":"Request mode 'navigate' is not allowed","messagePattern":"Request mode 'navigate' is not allowed","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/fetch/23_request.js","lineNumber":450,"sourceCode":"          (parsedReferrer.protocol === \"about:\" &&\n            parsedReferrer.pathname === \"client\")\n        ) {\n          request.referrer = \"client\";\n        } else {\n          request.referrer = parsedReferrer.href;\n        }\n      }\n    }\n\n    // 18. referrerPolicy\n    if (init.referrerPolicy !== undefined) {\n      request.referrerPolicy = init.referrerPolicy;\n    }\n\n    // 19. mode\n    if (init.mode !== undefined) {\n      if (init.mode === \"navigate\") {\n        throw new TypeError(\"Request mode 'navigate' is not allowed\");\n      }\n      request.mode = init.mode;\n    }\n\n    // 20. credentials\n    if (init.credentials !== undefined) {\n      request.credentialsMode = init.credentials;\n    }\n\n    // 21. cache\n    if (init.cache !== undefined) {\n      request.cacheMode = init.cache;\n    }\n\n    // If request's cache mode is \"only-if-cached\" and request's mode is not\n    // \"same-origin\", then throw a TypeError.\n    if (\n      request.cacheMode === \"only-if-cached\" && request.mode !== \"same-origin\"","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/fetch/23_request.js#L432-L468","documentation":"Request constructor step 19 rejects init.mode === 'navigate' with TypeError 'Request mode 'navigate' is not allowed'. Navigate mode is reserved for browser document loads and cannot be created from script per the Fetch spec; all other mode values ('same-origin', 'cors', 'no-cors') pass through unvalidated here.","triggerScenarios":"new Request(url, { mode: 'navigate' }) or fetch(url, { mode: 'navigate' }).","commonSituations":"Porting browser code or specs that mention navigate mode, generic option-forwarding wrappers that copy a mode value from elsewhere, or confusion between request.mode and navigation concepts.","solutions":["Remove the mode: 'navigate' option entirely (default mode is usually 'cors')","Use 'same-origin', 'cors', or 'no-cors' as appropriate","Strip unknown/unsupported keys in generic fetch wrappers before constructing Request"],"exampleFix":"// before\nawait fetch(url, { mode: 'navigate' });\n\n// after\nawait fetch(url, { mode: 'cors' });","handlingStrategy":"validation","validationCode":"const MODES = new Set(['same-origin', 'cors', 'no-cors']);\nfunction normalizeMode(mode) {\n  if (mode == null) return undefined;\n  const m = String(mode);\n  if (!MODES.has(m)) throw new Error(`unsupported mode: ${m} (navigate is not allowed)`);\n  return m;\n}","typeGuard":"/** @param {unknown} m */\nfunction isAllowedRequestMode(m) {\n  return m == null || ['same-origin', 'cors', 'no-cors'].includes(m);\n}","tryCatchPattern":null,"preventionTips":["Never forward mode values copied from specs or browser internals","Strip mode from option bags of generic wrappers unless explicitly supported","Remember default mode is 'cors' — usually you can omit it"],"tags":["fetch","request","mode","spec-compliance"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}