[{"data":1,"prerenderedAt":630,"buildId":631},["ShallowReactive",2],{"docs-navigation-en":3,"example-\u002Fexamples\u002Fclient-data":50,"example-surround-\u002Fexamples\u002Fclient-data":456,"examples-en":465},[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,{"id":51,"title":52,"body":53,"category":446,"description":447,"extension":448,"meta":449,"navigation":114,"order":118,"path":450,"seo":451,"stem":452,"uses":453,"__hash__":455},"examples_en\u002Fexamples\u002Fclient-data.md","JSON for client-side pages",{"type":54,"value":55,"toc":443},"minimark",[56,65,219,376,381,392,428,439],[57,58,59,60,64],"p",{},"Some pages load data in the browser: a store locator, a product filter, an events calendar. With ",[61,62,63],"code",{},"access: 'visitor'",", other websites cannot pull that JSON into their own pages through their visitors' browsers.",[66,67,73],"pre",{"className":68,"code":69,"filename":70,"language":71,"meta":72,"style":72},"language-ts shiki shiki-themes material-theme-lighter github-light github-dark","import { defineBffHandler } from '#bff-guard'\n\nexport default defineBffHandler(async (event) => {\n  const { prefecture } = getQuery(event)\n  return await findStores(String(prefecture ?? ''))\n})\n","server\u002Fapi\u002Fstores.get.ts","ts","",[61,74,75,109,116,151,180,211],{"__ignoreMap":72},[76,77,80,84,88,92,95,98,102,106],"span",{"class":78,"line":79},"line",1,[76,81,83],{"class":82},"sVHd0","import",[76,85,87],{"class":86},"sP7_E"," {",[76,89,91],{"class":90},"su5hD"," defineBffHandler",[76,93,94],{"class":86}," }",[76,96,97],{"class":82}," from",[76,99,101],{"class":100},"sjJ54"," '",[76,103,105],{"class":104},"s_sjI","#bff-guard",[76,107,108],{"class":100},"'\n",[76,110,112],{"class":78,"line":111},2,[76,113,115],{"emptyLinePlaceholder":114},true,"\n",[76,117,119,122,125,128,131,135,138,142,145,148],{"class":78,"line":118},3,[76,120,121],{"class":82},"export",[76,123,124],{"class":82}," default",[76,126,91],{"class":127},"sGLFI",[76,129,130],{"class":90},"(",[76,132,134],{"class":133},"sbsja","async",[76,136,137],{"class":86}," (",[76,139,141],{"class":140},"s99_P","event",[76,143,144],{"class":86},")",[76,146,147],{"class":133}," =>",[76,149,150],{"class":86}," {\n",[76,152,154,157,159,163,165,169,172,175,177],{"class":78,"line":153},4,[76,155,156],{"class":133},"  const",[76,158,87],{"class":86},[76,160,162],{"class":161},"s_hVV"," prefecture",[76,164,94],{"class":86},[76,166,168],{"class":167},"smGrS"," =",[76,170,171],{"class":127}," getQuery",[76,173,130],{"class":174},"skxfh",[76,176,141],{"class":90},[76,178,179],{"class":174},")\n",[76,181,183,186,189,192,194,197,199,202,205,208],{"class":78,"line":182},5,[76,184,185],{"class":82},"  return",[76,187,188],{"class":82}," await",[76,190,191],{"class":127}," findStores",[76,193,130],{"class":174},[76,195,196],{"class":127},"String",[76,198,130],{"class":174},[76,200,201],{"class":90},"prefecture",[76,203,204],{"class":167}," ??",[76,206,207],{"class":100}," ''",[76,209,210],{"class":174},"))\n",[76,212,214,217],{"class":78,"line":213},6,[76,215,216],{"class":86},"}",[76,218,179],{"class":90},[66,220,225],{"className":221,"code":222,"filename":223,"language":224,"meta":72,"style":72},"language-vue shiki shiki-themes material-theme-lighter github-light github-dark","\u003Cscript setup lang=\"ts\">\nconst prefecture = ref('tokyo')\n\n\u002F\u002F server: false — fetched by the browser, so it is a page fetch.\nconst { data: stores } = await useFetch('\u002Fapi\u002Fstores', {\n  query: { prefecture },\n  server: false,\n})\n\u003C\u002Fscript>\n","pages\u002Fstores.vue","vue",[61,226,227,256,280,284,290,329,344,359,366],{"__ignoreMap":72},[76,228,229,232,236,240,243,246,249,251,253],{"class":78,"line":79},[76,230,231],{"class":86},"\u003C",[76,233,235],{"class":234},"sQzsp","script",[76,237,239],{"class":238},"s9AJx"," setup",[76,241,242],{"class":238}," lang",[76,244,245],{"class":86},"=",[76,247,248],{"class":100},"\"",[76,250,71],{"class":104},[76,252,248],{"class":100},[76,254,255],{"class":86},">\n",[76,257,258,261,263,265,268,270,273,276,278],{"class":78,"line":111},[76,259,260],{"class":133},"const",[76,262,162],{"class":161},[76,264,168],{"class":167},[76,266,267],{"class":127}," ref",[76,269,130],{"class":90},[76,271,272],{"class":100},"'",[76,274,275],{"class":104},"tokyo",[76,277,272],{"class":100},[76,279,179],{"class":90},[76,281,282],{"class":78,"line":118},[76,283,115],{"emptyLinePlaceholder":114},[76,285,286],{"class":78,"line":153},[76,287,289],{"class":288},"sutJx","\u002F\u002F server: false — fetched by the browser, so it is a page fetch.\n",[76,291,292,294,296,300,303,306,308,310,312,315,317,319,322,324,327],{"class":78,"line":182},[76,293,260],{"class":133},[76,295,87],{"class":86},[76,297,299],{"class":298},"sucvu"," data",[76,301,302],{"class":86},":",[76,304,305],{"class":161}," stores",[76,307,94],{"class":86},[76,309,168],{"class":167},[76,311,188],{"class":82},[76,313,314],{"class":127}," useFetch",[76,316,130],{"class":90},[76,318,272],{"class":100},[76,320,321],{"class":104},"\u002Fapi\u002Fstores",[76,323,272],{"class":100},[76,325,326],{"class":86},",",[76,328,150],{"class":86},[76,330,331,334,336,338,341],{"class":78,"line":213},[76,332,333],{"class":174},"  query",[76,335,302],{"class":86},[76,337,87],{"class":86},[76,339,340],{"class":90}," prefecture ",[76,342,343],{"class":86},"},\n",[76,345,347,350,352,356],{"class":78,"line":346},7,[76,348,349],{"class":174},"  server",[76,351,302],{"class":86},[76,353,355],{"class":354},"syTEX"," false",[76,357,358],{"class":86},",\n",[76,360,362,364],{"class":78,"line":361},8,[76,363,216],{"class":86},[76,365,179],{"class":90},[76,367,369,372,374],{"class":78,"line":368},9,[76,370,371],{"class":86},"\u003C\u002F",[76,373,235],{"class":234},[76,375,255],{"class":86},[377,378,380],"h2",{"id":379},"the-same-data-during-ssr","The same data during SSR",[57,382,383,384,387,388,391],{},"If the page also renders the first result on the server, a visitor route would pass or fail depending on how the visitor arrived, because ",[61,385,386],{},"useFetch"," forwards the page request's ",[61,389,390],{},"Sec-Fetch-Site",". The rendered page shows the data to anyone anyway, so make that route public instead:",[66,393,395],{"className":68,"code":394,"filename":70,"language":71,"meta":72,"style":72},"export default defineBffHandler(handler, { access: 'public' })\n",[61,396,397],{"__ignoreMap":72},[76,398,399,401,403,405,408,410,412,415,417,419,422,424,426],{"class":78,"line":79},[76,400,121],{"class":82},[76,402,124],{"class":82},[76,404,91],{"class":127},[76,406,407],{"class":90},"(handler",[76,409,326],{"class":86},[76,411,87],{"class":86},[76,413,414],{"class":174}," access",[76,416,302],{"class":86},[76,418,101],{"class":100},[76,420,421],{"class":104},"public",[76,423,272],{"class":100},[76,425,94],{"class":86},[76,427,179],{"class":90},[57,429,430,431,434,435,438],{},"Choose per route: ",[61,432,433],{},"'visitor'"," for data the browser fetches, ",[61,436,437],{},"'public'"," for data the server renders into the page.",[440,441,442],"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 .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--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 pre.shiki code .sGLFI, html code.shiki .sGLFI{--shiki-light:#6182B8;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sbsja, html code.shiki .sbsja{--shiki-light:#9C3EDA;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .s99_P, html code.shiki .s99_P{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#E36209;--shiki-default-font-style:inherit;--shiki-dark:#FFAB70;--shiki-dark-font-style:inherit}html pre.shiki code .s_hVV, html code.shiki .s_hVV{--shiki-light:#90A4AE;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .skxfh, html code.shiki .skxfh{--shiki-light:#E53935;--shiki-default:#24292E;--shiki-dark:#E1E4E8}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 .sQzsp, html code.shiki .sQzsp{--shiki-light:#E53935;--shiki-default:#22863A;--shiki-dark:#85E89D}html pre.shiki code .s9AJx, html code.shiki .s9AJx{--shiki-light:#9C3EDA;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sutJx, html code.shiki .sutJx{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#6A737D;--shiki-dark-font-style:inherit}html pre.shiki code .sucvu, html code.shiki .sucvu{--shiki-light:#E53935;--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .syTEX, html code.shiki .syTEX{--shiki-light:#FF5370;--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":72,"searchDepth":111,"depth":111,"links":444},[445],{"id":379,"depth":111,"text":380},"visitor","Data that your pages fetch in the browser, kept from being embedded by other sites.","md",{},"\u002Fexamples\u002Fclient-data",{"title":52,"description":447},"examples\u002Fclient-data",[63,454,386],"access: 'public'","QoevD0ZmyX6yxyhzm4NpqwjKrcmcTGM8VOEvCGnK69k",[457,461],{"path":458,"title":459,"description":460,"category":446,"order":111},"\u002Fexamples\u002Fpaid-api-proxy","Search box that calls a paid API","Keep other sites and scripts from spending your API quota through your BFF.",{"path":462,"title":463,"description":464,"category":446,"order":153},"\u002Fexamples\u002Fmember-site-contact","Visitor routes inside a member app","Keep 'user' as the default and open a few routes to visitors without accounts.",[466,473,477,479,481,488,496,504,511,519,527,534,542,549,555,562,570,576,584,590,598,604,610,615,622],{"path":467,"title":468,"description":469,"category":446,"order":79,"uses":470},"\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.",[63,471,472],"@nuxtjs\u002Fturnstile","nuxt-security",{"path":458,"title":459,"description":460,"category":446,"order":111,"uses":474},[63,475,476],"rateLimiter","defineCachedFunction",{"path":450,"title":52,"description":447,"category":446,"order":118,"uses":478},[63,454,386],{"path":462,"title":463,"description":464,"category":446,"order":153,"uses":480},[63,14],{"path":482,"title":483,"description":484,"category":485,"order":79,"uses":486},"\u002Fexamples\u002Fnuxt-auth-utils","nuxt-auth-utils","Use the sealed Cookie session of nuxt-auth-utils as the user check.","auth",[483,487],"requireUserSession",{"path":489,"title":490,"description":491,"category":485,"order":111,"uses":492},"\u002Fexamples\u002Fsidebase-nuxt-auth","Auth.js with @sidebase\u002Fnuxt-auth","Check the Auth.js session, and accept the same JWT as a Bearer token.",[493,494,495],"@sidebase\u002Fnuxt-auth","getServerSession","getToken",{"path":497,"title":498,"description":499,"category":485,"order":118,"uses":500},"\u002Fexamples\u002Fsupabase","Supabase","Verify the Supabase session with getClaims, and tell bad tokens from outages.",[501,502,503],"@nuxtjs\u002Fsupabase","getClaims","isAuthRetryableFetchError",{"path":505,"title":506,"description":507,"category":485,"order":153,"uses":508},"\u002Fexamples\u002Fclerk","Clerk","Read the auth object that Clerk's middleware put on the event.",[509,510],"@clerk\u002Fnuxt","event.context.auth",{"path":512,"title":513,"description":514,"category":485,"order":182,"uses":515},"\u002Fexamples\u002Ffirebase","Firebase Authentication","Session Cookies for the browser, ID tokens for apps, and error codes mapped to 401 or 503.",[516,517,518],"firebase-admin","verifySessionCookie","verifyIdToken",{"path":520,"title":521,"description":522,"category":485,"order":213,"uses":523},"\u002Fexamples\u002Fjwt-jose","Any OpenID Connect provider (JWT)","Verify access tokens from Auth0, Keycloak, Cognito, Entra ID and others with jose.",[524,525,526],"jose","jwtVerify","createRemoteJWKSet",{"path":528,"title":529,"description":530,"category":531,"order":79,"uses":532},"\u002Fexamples\u002Fnuxt-security-rate-limit","Rate limits with nuxt-security","Slow down credential stuffing and token guessing before verifyUser runs.","security",[472,475,533],"routeRules",{"path":535,"title":536,"description":537,"category":531,"order":111,"uses":538},"\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.",[472,539,540,541],"headers","requestSizeLimiter","allowedMethodsRestricter",{"path":543,"title":544,"description":545,"category":531,"order":118,"uses":546},"\u002Fexamples\u002Fnuxt-csurf","CSRF tokens with nuxt-csurf","Add a synchronizer token on top of the origin check, without breaking Bearer clients.",[547,548,533],"nuxt-csurf","useCsrfFetch",{"path":550,"title":551,"description":552,"category":531,"order":153,"uses":553},"\u002Fexamples\u002Fturnstile","Bot checks on public routes with Turnstile","Public sign-in and sign-up routes skip verifyUser, so give them their own check.",[471,554],"verifyTurnstileToken",{"path":556,"title":557,"description":558,"category":531,"order":182,"uses":559},"\u002Fexamples\u002Fcors-bearer-clients","A frontend on another origin","CORS with nuxt-security for a separate app that calls the BFF with Bearer tokens.",[472,560,561],"corsHandler","viaBearer",{"path":563,"title":564,"description":565,"category":566,"order":79,"uses":567},"\u002Fexamples\u002Frecord-authorization","Per-record authorization","The guard says who the user is. The handler decides what they may touch.","patterns",[568,569],"event.context","createError",{"path":571,"title":572,"description":573,"category":566,"order":111,"uses":574},"\u002Fexamples\u002Froles","Roles and app-wide access","Reject whole groups of users in verifyUser, and check roles per route.",[14,575],"403",{"path":577,"title":578,"description":579,"category":566,"order":118,"uses":580},"\u002Fexamples\u002Fupstream-proxy","Calling an upstream API","Attach the user's token after the guard, never in middleware or routeRules.proxy.",[581,582,583],"$fetch","routeRules.proxy","server\u002Futils",{"path":585,"title":586,"description":587,"category":566,"order":153,"uses":588},"\u002Fexamples\u002Fssr-and-server-functions","SSR and server functions","Call your own API during server rendering, or skip HTTP entirely.",[386,589,583],"useRequestFetch",{"path":591,"title":592,"description":593,"category":566,"order":182,"uses":594},"\u002Fexamples\u002Fwebhooks","Webhooks","Server-to-server callbacks belong outside server\u002Fapi, with their own signature check.",[595,596,597],"server\u002Froutes","readRawBody","xssValidator",{"path":599,"title":600,"description":601,"category":566,"order":213,"uses":602},"\u002Fexamples\u002Fbearer-clients","Mobile apps and CLI tools","One BFF for the browser and for clients that send Bearer tokens.",[561,603],"Authorization",{"path":605,"title":606,"description":607,"category":566,"order":346,"uses":608},"\u002Fexamples\u002Fmore-route-folders","Checking more folders at build time","Extend routePatterns to server\u002Froutes and layers.",[609],"routePatterns",{"path":611,"title":612,"description":613,"category":566,"order":361,"uses":614},"\u002Fexamples\u002Fpublic-cache","Caching public data","Cache what is the same for everyone on a separate public route.",[476,454],{"path":616,"title":617,"description":618,"category":566,"order":368,"uses":619},"\u002Fexamples\u002Fclient-errors","Handling 401, 403 and 503 in the app","Sign out on 401, explain 403, retry on 503.",[620,621],"$fetch.create","onResponseError",{"path":623,"title":624,"description":625,"category":566,"order":626,"uses":627},"\u002Fexamples\u002Ftesting","Testing the protection","An end-to-end test that every protected route refuses anonymous calls.",10,[628,629],"@nuxt\u002Ftest-utils","vitest",1796451483527,"a99f93bd-e267-45a7-90df-9194cd77468d"]