[{"data":1,"prerenderedAt":371,"buildId":372},["ShallowReactive",2],{"docs-navigation-en":3,"examples-en":50,"page-\u002Fdocs\u002Fcontributing":237,"surround-\u002Fdocs\u002Fcontributing":367},[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":46,"body":239,"description":361,"extension":362,"meta":363,"navigation":364,"path":47,"seo":365,"stem":48,"__hash__":366},"docs_en\u002Fdocs\u002F10.contributing.md",{"type":240,"value":241,"toc":357},"minimark",[242,257,262,339,342,346,353],[243,244,245,246,249,250,252,253,256],"p",{},"Examples of ",[247,248,14],"code",{}," for more auth providers are welcome. Show where the existing session or Bearer check is called, and when ",[247,251,165],{}," is ",[247,254,255],{},"true",".",[258,259,261],"h2",{"id":260},"verify-locally","Verify locally",[263,264,269],"pre",{"className":265,"code":266,"language":267,"meta":268,"style":268},"language-bash shiki shiki-themes material-theme-lighter github-light github-dark","npm ci\nnpm run prepare:types\nnpx tsc --noEmit\nnpm test\nnpm run build\nBFF_TEST_DIST=1 npm test\n","bash","",[247,270,271,283,293,305,312,321],{"__ignoreMap":268},[272,273,275,279],"span",{"class":274,"line":56},"line",[272,276,278],{"class":277},"sbgvK","npm",[272,280,282],{"class":281},"s_sjI"," ci\n",[272,284,285,287,290],{"class":274,"line":65},[272,286,278],{"class":277},[272,288,289],{"class":281}," run",[272,291,292],{"class":281}," prepare:types\n",[272,294,295,298,301],{"class":274,"line":73},[272,296,297],{"class":277},"npx",[272,299,300],{"class":281}," tsc",[272,302,304],{"class":303},"stzsN"," --noEmit\n",[272,306,307,309],{"class":274,"line":81},[272,308,278],{"class":277},[272,310,311],{"class":281}," test\n",[272,313,314,316,318],{"class":274,"line":117},[272,315,278],{"class":277},[272,317,289],{"class":281},[272,319,320],{"class":281}," build\n",[272,322,323,327,331,334,337],{"class":274,"line":126},[272,324,326],{"class":325},"su5hD","BFF_TEST_DIST",[272,328,330],{"class":329},"smGrS","=",[272,332,333],{"class":281},"1",[272,335,336],{"class":277}," npm",[272,338,311],{"class":281},[243,340,341],{},"The integration tests start a local HTTP server. If you change what happens on failed authentication, public routes or the same-origin rules, add or update a test that checks the real HTTP response. If you extend the supported Nuxt, Nitro, h3 or ofetch versions, list the combinations you tested.",[258,343,345],{"id":344},"reporting-a-problem","Reporting a problem",[243,347,348,349,352],{},"Include the Node.js and dependency versions, the relevant ",[247,350,351],{},"bffGuard"," options, and the status you expected and got. Use dummy Cookies and tokens; never paste real credentials or user data.",[354,355,356],"style",{},"html pre.shiki code .sbgvK, html code.shiki .sbgvK{--shiki-light:#E2931D;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .stzsN, html code.shiki .stzsN{--shiki-light:#91B859;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}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);}",{"title":268,"searchDepth":65,"depth":65,"links":358},[359,360],{"id":260,"depth":65,"text":261},{"id":344,"depth":65,"text":345},"Verify a change locally, and what to include in a report.","md",{},true,{"title":46,"description":361},"oBTy9hL4mOmXWb6U9yNnYWFNGhbpFjagsMkn1SuZiec",[368,370],{"title":42,"path":43,"stem":44,"description":369,"children":-1},"Move from a global middleware or an older version to defineBffHandler.",null,1796451485387,"a99f93bd-e267-45a7-90df-9194cd77468d"]