[{"data":1,"prerenderedAt":792,"buildId":793},["ShallowReactive",2],{"docs-navigation-en":3,"examples-en":50,"page-\u002Fdocs\u002Fconfiguration":237,"surround-\u002Fdocs\u002Fconfiguration":787},[4],{"title":5,"path":6,"stem":7,"children":8,"page":49},"Docs","\u002Fdocs","docs",[9,13,17,21,25,29,33,37,41,45],{"title":10,"path":11,"stem":12},"Getting started","\u002Fdocs\u002Fgetting-started","docs\u002F01.getting-started",{"title":14,"path":15,"stem":16},"verifyUser","\u002Fdocs\u002Fverify-user","docs\u002F02.verify-user",{"title":18,"path":19,"stem":20},"Sites without users","\u002Fdocs\u002Fsites-without-users","docs\u002F03.sites-without-users",{"title":22,"path":23,"stem":24},"Build-time route check","\u002Fdocs\u002Froute-coverage","docs\u002F04.route-coverage",{"title":26,"path":27,"stem":28},"Public routes","\u002Fdocs\u002Fpublic-routes","docs\u002F05.public-routes",{"title":30,"path":31,"stem":32},"Same-origin writes","\u002Fdocs\u002Fsame-origin","docs\u002F06.same-origin",{"title":34,"path":35,"stem":36},"Scope and caching","\u002Fdocs\u002Fscope","docs\u002F07.scope",{"title":38,"path":39,"stem":40},"Configuration","\u002Fdocs\u002Fconfiguration","docs\u002F08.configuration",{"title":42,"path":43,"stem":44},"Migrating an existing BFF guard","\u002Fdocs\u002Fmigration","docs\u002F09.migration",{"title":46,"path":47,"stem":48},"Contributing","\u002Fdocs\u002Fcontributing","docs\u002F10.contributing",false,[51,61,69,77,83,90,98,106,113,122,131,138,146,153,159,166,174,180,188,194,202,208,215,221,229],{"path":52,"title":53,"description":54,"category":55,"order":56,"uses":57},"\u002Fexamples\u002Fcontact-form","Contact form on a corporate site","A mail-sending route that only your own pages can call, with a bot check and a rate limit.","visitor",1,[58,59,60],"access: 'visitor'","@nuxtjs\u002Fturnstile","nuxt-security",{"path":62,"title":63,"description":64,"category":55,"order":65,"uses":66},"\u002Fexamples\u002Fpaid-api-proxy","Search box that calls a paid API","Keep other sites and scripts from spending your API quota through your BFF.",2,[58,67,68],"rateLimiter","defineCachedFunction",{"path":70,"title":71,"description":72,"category":55,"order":73,"uses":74},"\u002Fexamples\u002Fclient-data","JSON for client-side pages","Data that your pages fetch in the browser, kept from being embedded by other sites.",3,[58,75,76],"access: 'public'","useFetch",{"path":78,"title":79,"description":80,"category":55,"order":81,"uses":82},"\u002Fexamples\u002Fmember-site-contact","Visitor routes inside a member app","Keep 'user' as the default and open a few routes to visitors without accounts.",4,[58,14],{"path":84,"title":85,"description":86,"category":87,"order":56,"uses":88},"\u002Fexamples\u002Fnuxt-auth-utils","nuxt-auth-utils","Use the sealed Cookie session of nuxt-auth-utils as the user check.","auth",[85,89],"requireUserSession",{"path":91,"title":92,"description":93,"category":87,"order":65,"uses":94},"\u002Fexamples\u002Fsidebase-nuxt-auth","Auth.js with @sidebase\u002Fnuxt-auth","Check the Auth.js session, and accept the same JWT as a Bearer token.",[95,96,97],"@sidebase\u002Fnuxt-auth","getServerSession","getToken",{"path":99,"title":100,"description":101,"category":87,"order":73,"uses":102},"\u002Fexamples\u002Fsupabase","Supabase","Verify the Supabase session with getClaims, and tell bad tokens from outages.",[103,104,105],"@nuxtjs\u002Fsupabase","getClaims","isAuthRetryableFetchError",{"path":107,"title":108,"description":109,"category":87,"order":81,"uses":110},"\u002Fexamples\u002Fclerk","Clerk","Read the auth object that Clerk's middleware put on the event.",[111,112],"@clerk\u002Fnuxt","event.context.auth",{"path":114,"title":115,"description":116,"category":87,"order":117,"uses":118},"\u002Fexamples\u002Ffirebase","Firebase Authentication","Session Cookies for the browser, ID tokens for apps, and error codes mapped to 401 or 503.",5,[119,120,121],"firebase-admin","verifySessionCookie","verifyIdToken",{"path":123,"title":124,"description":125,"category":87,"order":126,"uses":127},"\u002Fexamples\u002Fjwt-jose","Any OpenID Connect provider (JWT)","Verify access tokens from Auth0, Keycloak, Cognito, Entra ID and others with jose.",6,[128,129,130],"jose","jwtVerify","createRemoteJWKSet",{"path":132,"title":133,"description":134,"category":135,"order":56,"uses":136},"\u002Fexamples\u002Fnuxt-security-rate-limit","Rate limits with nuxt-security","Slow down credential stuffing and token guessing before verifyUser runs.","security",[60,67,137],"routeRules",{"path":139,"title":140,"description":141,"category":135,"order":65,"uses":142},"\u002Fexamples\u002Fnuxt-security-headers","Headers, CSP and request limits with nuxt-security","A baseline nuxt-security setup next to the guard, tuned for a BFF.",[60,143,144,145],"headers","requestSizeLimiter","allowedMethodsRestricter",{"path":147,"title":148,"description":149,"category":135,"order":73,"uses":150},"\u002Fexamples\u002Fnuxt-csurf","CSRF tokens with nuxt-csurf","Add a synchronizer token on top of the origin check, without breaking Bearer clients.",[151,152,137],"nuxt-csurf","useCsrfFetch",{"path":154,"title":155,"description":156,"category":135,"order":81,"uses":157},"\u002Fexamples\u002Fturnstile","Bot checks on public routes with Turnstile","Public sign-in and sign-up routes skip verifyUser, so give them their own check.",[59,158],"verifyTurnstileToken",{"path":160,"title":161,"description":162,"category":135,"order":117,"uses":163},"\u002Fexamples\u002Fcors-bearer-clients","A frontend on another origin","CORS with nuxt-security for a separate app that calls the BFF with Bearer tokens.",[60,164,165],"corsHandler","viaBearer",{"path":167,"title":168,"description":169,"category":170,"order":56,"uses":171},"\u002Fexamples\u002Frecord-authorization","Per-record authorization","The guard says who the user is. The handler decides what they may touch.","patterns",[172,173],"event.context","createError",{"path":175,"title":176,"description":177,"category":170,"order":65,"uses":178},"\u002Fexamples\u002Froles","Roles and app-wide access","Reject whole groups of users in verifyUser, and check roles per route.",[14,179],"403",{"path":181,"title":182,"description":183,"category":170,"order":73,"uses":184},"\u002Fexamples\u002Fupstream-proxy","Calling an upstream API","Attach the user's token after the guard, never in middleware or routeRules.proxy.",[185,186,187],"$fetch","routeRules.proxy","server\u002Futils",{"path":189,"title":190,"description":191,"category":170,"order":81,"uses":192},"\u002Fexamples\u002Fssr-and-server-functions","SSR and server functions","Call your own API during server rendering, or skip HTTP entirely.",[76,193,187],"useRequestFetch",{"path":195,"title":196,"description":197,"category":170,"order":117,"uses":198},"\u002Fexamples\u002Fwebhooks","Webhooks","Server-to-server callbacks belong outside server\u002Fapi, with their own signature check.",[199,200,201],"server\u002Froutes","readRawBody","xssValidator",{"path":203,"title":204,"description":205,"category":170,"order":126,"uses":206},"\u002Fexamples\u002Fbearer-clients","Mobile apps and CLI tools","One BFF for the browser and for clients that send Bearer tokens.",[165,207],"Authorization",{"path":209,"title":210,"description":211,"category":170,"order":212,"uses":213},"\u002Fexamples\u002Fmore-route-folders","Checking more folders at build time","Extend routePatterns to server\u002Froutes and layers.",7,[214],"routePatterns",{"path":216,"title":217,"description":218,"category":170,"order":219,"uses":220},"\u002Fexamples\u002Fpublic-cache","Caching public data","Cache what is the same for everyone on a separate public route.",8,[68,75],{"path":222,"title":223,"description":224,"category":170,"order":225,"uses":226},"\u002Fexamples\u002Fclient-errors","Handling 401, 403 and 503 in the app","Sign out on 401, explain 403, retry on 503.",9,[227,228],"$fetch.create","onResponseError",{"path":230,"title":231,"description":232,"category":170,"order":233,"uses":234},"\u002Fexamples\u002Ftesting","Testing the protection","An end-to-end test that every protected route refuses anonymous calls.",10,[235,236],"@nuxt\u002Ftest-utils","vitest",{"id":238,"title":38,"body":239,"description":782,"extension":783,"meta":784,"navigation":573,"path":39,"seo":785,"stem":40,"__hash__":786},"docs_en\u002Fdocs\u002F08.configuration.md",{"type":240,"value":241,"toc":777},"minimark",[242,428,535,539,620,669,673,719,726,730,773],[243,244,250],"pre",{"className":245,"code":246,"filename":247,"language":248,"meta":249,"style":249},"language-ts shiki shiki-themes material-theme-lighter github-light github-dark","export default defineNuxtConfig({\n  modules: ['@kurashina-design\u002Fnuxt-bff-guard'],\n  bffGuard: {\n    access: 'user',\n    verifyUser: '.\u002Fserver\u002Fauth\u002Fverify-user.ts',\n    routePatterns: ['server\u002Fapi\u002F**'],\n    writeMethods: ['POST', 'PUT', 'PATCH', 'DELETE'],\n  },\n})\n","nuxt.config.ts","ts","",[251,252,253,276,304,314,331,347,367,415,420],"code",{"__ignoreMap":249},[254,255,257,261,264,268,272],"span",{"class":256,"line":56},"line",[254,258,260],{"class":259},"sVHd0","export",[254,262,263],{"class":259}," default",[254,265,267],{"class":266},"sGLFI"," defineNuxtConfig",[254,269,271],{"class":270},"su5hD","(",[254,273,275],{"class":274},"sP7_E","{\n",[254,277,278,282,285,288,292,296,298,301],{"class":256,"line":65},[254,279,281],{"class":280},"skxfh","  modules",[254,283,284],{"class":274},":",[254,286,287],{"class":270}," [",[254,289,291],{"class":290},"sjJ54","'",[254,293,295],{"class":294},"s_sjI","@kurashina-design\u002Fnuxt-bff-guard",[254,297,291],{"class":290},[254,299,300],{"class":270},"]",[254,302,303],{"class":274},",\n",[254,305,306,309,311],{"class":256,"line":73},[254,307,308],{"class":280},"  bffGuard",[254,310,284],{"class":274},[254,312,313],{"class":274}," {\n",[254,315,316,319,321,324,327,329],{"class":256,"line":81},[254,317,318],{"class":280},"    access",[254,320,284],{"class":274},[254,322,323],{"class":290}," '",[254,325,326],{"class":294},"user",[254,328,291],{"class":290},[254,330,303],{"class":274},[254,332,333,336,338,340,343,345],{"class":256,"line":117},[254,334,335],{"class":280},"    verifyUser",[254,337,284],{"class":274},[254,339,323],{"class":290},[254,341,342],{"class":294},".\u002Fserver\u002Fauth\u002Fverify-user.ts",[254,344,291],{"class":290},[254,346,303],{"class":274},[254,348,349,352,354,356,358,361,363,365],{"class":256,"line":126},[254,350,351],{"class":280},"    routePatterns",[254,353,284],{"class":274},[254,355,287],{"class":270},[254,357,291],{"class":290},[254,359,360],{"class":294},"server\u002Fapi\u002F**",[254,362,291],{"class":290},[254,364,300],{"class":270},[254,366,303],{"class":274},[254,368,369,372,374,376,378,381,383,386,388,391,393,395,397,400,402,404,406,409,411,413],{"class":256,"line":212},[254,370,371],{"class":280},"    writeMethods",[254,373,284],{"class":274},[254,375,287],{"class":270},[254,377,291],{"class":290},[254,379,380],{"class":294},"POST",[254,382,291],{"class":290},[254,384,385],{"class":274},",",[254,387,323],{"class":290},[254,389,390],{"class":294},"PUT",[254,392,291],{"class":290},[254,394,385],{"class":274},[254,396,323],{"class":290},[254,398,399],{"class":294},"PATCH",[254,401,291],{"class":290},[254,403,385],{"class":274},[254,405,323],{"class":290},[254,407,408],{"class":294},"DELETE",[254,410,291],{"class":290},[254,412,300],{"class":270},[254,414,303],{"class":274},[254,416,417],{"class":256,"line":219},[254,418,419],{"class":274},"  },\n",[254,421,422,425],{"class":256,"line":225},[254,423,424],{"class":274},"}",[254,426,427],{"class":270},")\n",[429,430,431,447],"table",{},[432,433,434],"thead",{},[435,436,437,441,444],"tr",{},[438,439,440],"th",{},"Option",[438,442,443],{},"Default",[438,445,446],{},"Description",[448,449,450,477,497,517],"tbody",{},[435,451,452,458,463],{},[453,454,455],"td",{},[251,456,457],{},"access",[453,459,460],{},[251,461,462],{},"'user'",[453,464,465,466,468,469,472,473,476],{},"Default protection of every route: ",[251,467,462],{}," or ",[251,470,471],{},"'visitor'",". See ",[474,475,18],"a",{"href":19},".",[435,478,479,483,486],{},[453,480,481],{},[251,482,14],{},[453,484,485],{},"none",[453,487,488,489,491,492,494,495,476],{},"Server file whose default export is the ",[474,490,14],{"href":15}," function. Relative to the project root, or absolute. Required in production when ",[251,493,457],{}," is ",[251,496,462],{},[435,498,499,503,508],{},[453,500,501],{},[251,502,214],{},[453,504,505],{},[251,506,507],{},"['server\u002Fapi\u002F**']",[453,509,510,511,514,515,476],{},"Globs of route files that must use ",[251,512,513],{},"defineBffHandler",". Your array replaces the default. See ",[474,516,22],{"href":23},[435,518,519,524,529],{},[453,520,521],{},[251,522,523],{},"writeMethods",[453,525,526],{},[251,527,528],{},"['POST', 'PUT', 'PATCH', 'DELETE']",[453,530,531,532,476],{},"Methods that need the ",[474,533,534],{"href":31},"same-origin check",[536,537,513],"h2",{"id":538},"definebffhandler",[243,540,542],{"className":245,"code":541,"language":248,"meta":249,"style":249},"import { defineBffHandler } from '#bff-guard'\n\ndefineBffHandler(handler, { access?: 'user' | 'visitor' | 'public' })\n",[251,543,544,569,575],{"__ignoreMap":249},[254,545,546,549,552,555,558,561,563,566],{"class":256,"line":56},[254,547,548],{"class":259},"import",[254,550,551],{"class":274}," {",[254,553,554],{"class":270}," defineBffHandler",[254,556,557],{"class":274}," }",[254,559,560],{"class":259}," from",[254,562,323],{"class":290},[254,564,565],{"class":294},"#bff-guard",[254,567,568],{"class":290},"'\n",[254,570,571],{"class":256,"line":65},[254,572,574],{"emptyLinePlaceholder":573},true,"\n",[254,576,577,579,582,584,586,589,591,593,595,597,601,603,605,607,609,611,614,616,618],{"class":256,"line":73},[254,578,513],{"class":266},[254,580,581],{"class":270},"(handler",[254,583,385],{"class":274},[254,585,551],{"class":274},[254,587,588],{"class":270}," access?",[254,590,284],{"class":274},[254,592,323],{"class":290},[254,594,326],{"class":294},[254,596,291],{"class":290},[254,598,600],{"class":599},"smGrS"," |",[254,602,323],{"class":290},[254,604,55],{"class":294},[254,606,291],{"class":290},[254,608,600],{"class":599},[254,610,323],{"class":290},[254,612,613],{"class":294},"public",[254,615,291],{"class":290},[254,617,557],{"class":274},[254,619,427],{"class":270},[429,621,622,632],{},[432,623,624],{},[435,625,626,628,630],{},[438,627,440],{},[438,629,443],{},[438,631,446],{},[448,633,634],{},[435,635,636,640,646],{},[453,637,638],{},[251,639,457],{},[453,641,642,643,645],{},"the ",[251,644,457],{}," option",[453,647,648,650,651,653,654,656,657,660,661,664,665,668],{},[251,649,462],{},": ",[251,652,14],{}," and the same-origin check for writes. ",[251,655,471],{},": only fetches from your own pages (",[251,658,659],{},"Sec-Fetch-Site: same-origin","), every method. ",[251,662,663],{},"'public'",": no user check; writes still need your origin. ",[251,666,667],{},"Cache-Control"," applies to all.",[536,670,672],{"id":671},"responses","Responses",[429,674,675,685],{},[432,676,677],{},[435,678,679,682],{},[438,680,681],{},"Status",[438,683,684],{},"When",[448,686,687,697,706],{},[435,688,689,692],{},[453,690,691],{},"401",[453,693,694,696],{},[251,695,14],{}," is missing, returned something invalid, or threw a 4xx other than 403.",[435,698,699,701],{},[453,700,179],{},[453,702,703,705],{},[251,704,14],{}," threw 403, a write failed the same-origin check, or a visitor route got anything but a fetch from your own pages.",[435,707,708,711],{},[453,709,710],{},"503",[453,712,713,715,716,476],{},[251,714,14],{}," threw an error without a 4xx ",[251,717,718],{},"statusCode",[720,721,722,723,476],"p",{},"Every response from a wrapped handler gets ",[251,724,725],{},"Cache-Control: private, no-store",[536,727,729],{"id":728},"startup-errors","Startup errors",[731,732,733,746,767],"ul",{},[734,735,736,739,740,742,743,745],"li",{},[251,737,738],{},"verifyUser is required in production",": set ",[251,741,14],{},", or ",[251,744,58],{}," if the site has no accounts.",[734,747,748,751,752,755,756,759,760,763,764,476],{},[251,749,750],{},"Legacy configuration detected",": remove ",[251,753,754],{},"apiPrefix",", ",[251,757,758],{},"publicPaths"," and ",[251,761,762],{},"internalRequests"," from an older version. See ",[474,765,766],{"href":43},"Migration",[734,768,769,772],{},[251,770,771],{},"Nitro 2 is required",": the module does not support Nitro 3 yet.",[774,775,776],"style",{},"html pre.shiki code .sVHd0, html code.shiki .sVHd0{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#F97583;--shiki-dark-font-style:inherit}html pre.shiki code .sGLFI, html code.shiki .sGLFI{--shiki-light:#6182B8;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .skxfh, html code.shiki .skxfh{--shiki-light:#E53935;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sjJ54, html code.shiki .sjJ54{--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}",{"title":249,"searchDepth":65,"depth":65,"links":778},[779,780,781],{"id":538,"depth":65,"text":513},{"id":671,"depth":65,"text":672},{"id":728,"depth":65,"text":729},"All options of the bffGuard key.","md",{},{"title":38,"description":782},"KUlGKAUjpr_v7K01gCkBrhVksG0aMMbsvoatpeYvFvo",[788,790],{"title":34,"path":35,"stem":36,"description":789,"children":-1},"What the guard covers, and the setups that would bypass it.",{"title":42,"path":43,"stem":44,"description":791,"children":-1},"Move from a global middleware or an older version to defineBffHandler.",1796451485352,"a99f93bd-e267-45a7-90df-9194cd77468d"]