[{"data":1,"prerenderedAt":454,"buildId":455},["ShallowReactive",2],{"docs-navigation-ja":3,"examples-ja":55,"page-\u002Fja\u002Fdocs\u002Fpublic-routes":242,"surround-\u002Fja\u002Fdocs\u002Fpublic-routes":449},[4],{"title":5,"path":6,"stem":7,"children":8,"page":54},"Ja","\u002Fja","ja",[9],{"title":10,"path":11,"stem":12,"children":13,"page":54},"Docs","\u002Fja\u002Fdocs","ja\u002Fdocs",[14,18,22,26,30,34,38,42,46,50],{"title":15,"path":16,"stem":17},"はじめる","\u002Fja\u002Fdocs\u002Fgetting-started","ja\u002Fdocs\u002F01.getting-started",{"title":19,"path":20,"stem":21},"verifyUser","\u002Fja\u002Fdocs\u002Fverify-user","ja\u002Fdocs\u002F02.verify-user",{"title":23,"path":24,"stem":25},"ユーザーのいないサイト","\u002Fja\u002Fdocs\u002Fsites-without-users","ja\u002Fdocs\u002F03.sites-without-users",{"title":27,"path":28,"stem":29},"ビルド時のルート検査","\u002Fja\u002Fdocs\u002Froute-coverage","ja\u002Fdocs\u002F04.route-coverage",{"title":31,"path":32,"stem":33},"公開ルート","\u002Fja\u002Fdocs\u002Fpublic-routes","ja\u002Fdocs\u002F05.public-routes",{"title":35,"path":36,"stem":37},"同一オリジンからの更新","\u002Fja\u002Fdocs\u002Fsame-origin","ja\u002Fdocs\u002F06.same-origin",{"title":39,"path":40,"stem":41},"適用範囲とキャッシュ","\u002Fja\u002Fdocs\u002Fscope","ja\u002Fdocs\u002F07.scope",{"title":43,"path":44,"stem":45},"設定","\u002Fja\u002Fdocs\u002Fconfiguration","ja\u002Fdocs\u002F08.configuration",{"title":47,"path":48,"stem":49},"既存の BFF ガードからの移行","\u002Fja\u002Fdocs\u002Fmigration","ja\u002Fdocs\u002F09.migration",{"title":51,"path":52,"stem":53},"開発に参加する","\u002Fja\u002Fdocs\u002Fcontributing","ja\u002Fdocs\u002F10.contributing",false,[56,66,74,82,88,95,103,111,118,127,136,143,151,158,164,171,179,185,193,199,207,213,220,226,234],{"path":57,"title":58,"description":59,"category":60,"order":61,"uses":62},"\u002Fja\u002Fexamples\u002Fcontact-form","コーポレートサイトのお問い合わせ","自分のページからしか呼べない、メール送信のルート。ボット対策とレート制限も加えます。","visitor",1,[63,64,65],"access: 'visitor'","@nuxtjs\u002Fturnstile","nuxt-security",{"path":67,"title":68,"description":69,"category":60,"order":70,"uses":71},"\u002Fja\u002Fexamples\u002Fpaid-api-proxy","有料の API を呼ぶ検索ボックス","他のサイトやスクリプトが、あなたの BFF を通して API の利用枠を使うのを防ぎます。",2,[63,72,73],"rateLimiter","defineCachedFunction",{"path":75,"title":76,"description":77,"category":60,"order":78,"uses":79},"\u002Fja\u002Fexamples\u002Fclient-data","クライアント側で読み込む JSON","ページがブラウザーで取得するデータを、他のサイトに埋め込まれないようにします。",3,[63,80,81],"access: 'public'","useFetch",{"path":83,"title":84,"description":85,"category":60,"order":86,"uses":87},"\u002Fja\u002Fexamples\u002Fmember-site-contact","会員向けアプリの中の visitor のルート","既定は 'user' のまま、いくつかのルートだけアカウントの無い訪問者に開きます。",4,[63,19],{"path":89,"title":90,"description":91,"category":92,"order":61,"uses":93},"\u002Fja\u002Fexamples\u002Fnuxt-auth-utils","nuxt-auth-utils","nuxt-auth-utils の暗号化した Cookie セッションで利用者を確かめます。","auth",[90,94],"requireUserSession",{"path":96,"title":97,"description":98,"category":92,"order":70,"uses":99},"\u002Fja\u002Fexamples\u002Fsidebase-nuxt-auth","Auth.js（@sidebase\u002Fnuxt-auth）","Auth.js のセッションを確かめ、同じ JWT を Bearer トークンとしても受け付けます。",[100,101,102],"@sidebase\u002Fnuxt-auth","getServerSession","getToken",{"path":104,"title":105,"description":106,"category":92,"order":78,"uses":107},"\u002Fja\u002Fexamples\u002Fsupabase","Supabase","getClaims で Supabase のセッションを確かめ、無効なトークンと障害を分けます。",[108,109,110],"@nuxtjs\u002Fsupabase","getClaims","isAuthRetryableFetchError",{"path":112,"title":113,"description":114,"category":92,"order":86,"uses":115},"\u002Fja\u002Fexamples\u002Fclerk","Clerk","Clerk のミドルウェアが event に置いた認証情報を読みます。",[116,117],"@clerk\u002Fnuxt","event.context.auth",{"path":119,"title":120,"description":121,"category":92,"order":122,"uses":123},"\u002Fja\u002Fexamples\u002Ffirebase","Firebase Authentication","ブラウザーにはセッション Cookie、アプリには ID トークン。エラーコードを 401 と 503 に振り分けます。",5,[124,125,126],"firebase-admin","verifySessionCookie","verifyIdToken",{"path":128,"title":129,"description":130,"category":92,"order":131,"uses":132},"\u002Fja\u002Fexamples\u002Fjwt-jose","OpenID Connect の認証基盤（JWT）","Auth0、Keycloak、Cognito、Entra ID などのアクセストークンを jose で検証します。",6,[133,134,135],"jose","jwtVerify","createRemoteJWKSet",{"path":137,"title":138,"description":139,"category":140,"order":61,"uses":141},"\u002Fja\u002Fexamples\u002Fnuxt-security-rate-limit","nuxt-security でレート制限","verifyUser が動く前に、資格情報の総当たりやトークンの推測を遅らせます。","security",[65,72,142],"routeRules",{"path":144,"title":145,"description":146,"category":140,"order":70,"uses":147},"\u002Fja\u002Fexamples\u002Fnuxt-security-headers","nuxt-security でヘッダー、CSP、リクエストの制限","ガードと並べる nuxt-security の基本の設定を、BFF 向けに調整します。",[65,148,149,150],"headers","requestSizeLimiter","allowedMethodsRestricter",{"path":152,"title":153,"description":154,"category":140,"order":78,"uses":155},"\u002Fja\u002Fexamples\u002Fnuxt-csurf","nuxt-csurf で CSRF トークン","オリジンの確認に CSRF トークンを重ね、Bearer のクライアントは壊さないようにします。",[156,157,142],"nuxt-csurf","useCsrfFetch",{"path":159,"title":160,"description":161,"category":140,"order":86,"uses":162},"\u002Fja\u002Fexamples\u002Fturnstile","Turnstile で公開ルートのボット対策","公開のサインインや登録のルートは verifyUser を呼ばないので、独自の確認を加えます。",[64,163],"verifyTurnstileToken",{"path":165,"title":166,"description":167,"category":140,"order":122,"uses":168},"\u002Fja\u002Fexamples\u002Fcors-bearer-clients","別のオリジンのフロントエンド","Bearer トークンで BFF を呼ぶ別のアプリのために、nuxt-security で CORS を設定します。",[65,169,170],"corsHandler","viaBearer",{"path":172,"title":173,"description":174,"category":175,"order":61,"uses":176},"\u002Fja\u002Fexamples\u002Frecord-authorization","レコードごとの認可","利用者が誰かはガードが決め、何に触れてよいかはハンドラーが決めます。","patterns",[177,178],"event.context","createError",{"path":180,"title":181,"description":182,"category":175,"order":70,"uses":183},"\u002Fja\u002Fexamples\u002Froles","ロールとアプリ全体の利用資格","利用者のまとまりは verifyUser で拒否し、ロールはルートごとに確かめます。",[19,184],"403",{"path":186,"title":187,"description":188,"category":175,"order":78,"uses":189},"\u002Fja\u002Fexamples\u002Fupstream-proxy","上流の API を呼ぶ","利用者のトークンはガードの後で付けます。ミドルウェアや routeRules.proxy では付けません。",[190,191,192],"$fetch","routeRules.proxy","server\u002Futils",{"path":194,"title":195,"description":196,"category":175,"order":86,"uses":197},"\u002Fja\u002Fexamples\u002Fssr-and-server-functions","SSR とサーバーの関数","サーバーでの描画中に自分の API を呼ぶ方法と、HTTP を使わない方法。",[81,198,192],"useRequestFetch",{"path":200,"title":201,"description":202,"category":175,"order":122,"uses":203},"\u002Fja\u002Fexamples\u002Fwebhooks","Webhook","サーバー間のコールバックは server\u002Fapi の外に置き、署名を自分で確かめます。",[204,205,206],"server\u002Froutes","readRawBody","xssValidator",{"path":208,"title":209,"description":210,"category":175,"order":131,"uses":211},"\u002Fja\u002Fexamples\u002Fbearer-clients","モバイルアプリと CLI","ブラウザーと、Bearer トークンを送るクライアントを、ひとつの BFF で受けます。",[170,212],"Authorization",{"path":214,"title":215,"description":216,"category":175,"order":217,"uses":218},"\u002Fja\u002Fexamples\u002Fmore-route-folders","ビルド時に検査するフォルダーを増やす","routePatterns を server\u002Froutes やレイヤーに広げます。",7,[219],"routePatterns",{"path":221,"title":222,"description":223,"category":175,"order":224,"uses":225},"\u002Fja\u002Fexamples\u002Fpublic-cache","公開データのキャッシュ","誰にでも同じものは、別の公開ルートでキャッシュします。",8,[73,80],{"path":227,"title":228,"description":229,"category":175,"order":230,"uses":231},"\u002Fja\u002Fexamples\u002Fclient-errors","アプリで 401、403、503 を扱う","401 ならサインインへ、403 なら説明を、503 なら再試行を。",9,[232,233],"$fetch.create","onResponseError",{"path":235,"title":236,"description":237,"category":175,"order":238,"uses":239},"\u002Fja\u002Fexamples\u002Ftesting","保護をテストする","保護するすべてのルートが匿名の呼び出しを拒むことを、エンドツーエンドで確かめます。",10,[240,241],"@nuxt\u002Ftest-utils","vitest",{"id":243,"title":31,"body":244,"description":444,"extension":445,"meta":446,"navigation":299,"path":32,"seo":447,"stem":33,"__hash__":448},"docs_ja\u002Fja\u002Fdocs\u002F05.public-routes.md",{"type":245,"value":246,"toc":440},"minimark",[247,251,367,382,386,389,405,419,422,433,436],[248,249,250],"p",{},"サインインする前から動く必要があるルートがあります。ルート自身に印を付けます。",[252,253,259],"pre",{"className":254,"code":255,"filename":256,"language":257,"meta":258,"style":258},"language-ts shiki shiki-themes material-theme-lighter github-light github-dark","import { defineBffHandler } from '#bff-guard'\n\nexport default defineBffHandler(() => ({ ok: true }), { access: 'public' })\n","server\u002Fapi\u002Fhealth.get.ts","ts","",[260,261,262,295,301],"code",{"__ignoreMap":258},[263,264,266,270,274,278,281,284,288,292],"span",{"class":265,"line":61},"line",[263,267,269],{"class":268},"sVHd0","import",[263,271,273],{"class":272},"sP7_E"," {",[263,275,277],{"class":276},"su5hD"," defineBffHandler",[263,279,280],{"class":272}," }",[263,282,283],{"class":268}," from",[263,285,287],{"class":286},"sjJ54"," '",[263,289,291],{"class":290},"s_sjI","#bff-guard",[263,293,294],{"class":286},"'\n",[263,296,297],{"class":265,"line":70},[263,298,300],{"emptyLinePlaceholder":299},true,"\n",[263,302,303,306,309,312,315,318,322,325,328,332,335,339,341,344,347,349,352,354,356,359,362,364],{"class":265,"line":78},[263,304,305],{"class":268},"export",[263,307,308],{"class":268}," default",[263,310,277],{"class":311},"sGLFI",[263,313,314],{"class":276},"(",[263,316,317],{"class":272},"()",[263,319,321],{"class":320},"sbsja"," =>",[263,323,324],{"class":276}," (",[263,326,327],{"class":272},"{",[263,329,331],{"class":330},"skxfh"," ok",[263,333,334],{"class":272},":",[263,336,338],{"class":337},"syTEX"," true",[263,340,280],{"class":272},[263,342,343],{"class":276},")",[263,345,346],{"class":272},",",[263,348,273],{"class":272},[263,350,351],{"class":330}," access",[263,353,334],{"class":272},[263,355,287],{"class":286},[263,357,358],{"class":290},"public",[263,360,361],{"class":286},"'",[263,363,280],{"class":272},[263,365,366],{"class":276},")\n",[248,368,369,370,372,373,376,377,381],{},"公開ルートでは ",[260,371,19],{}," を呼びません。それでも ",[260,374,375],{},"Cache-Control: private, no-store"," は付き、更新には",[378,379,380],"a",{"href":36},"同一オリジンの確認","が必要です。",[383,384,385],"h2",{"id":385},"公開すべきルートを見つける",[248,387,388],{},"新しいブラウザーのプロファイルで、サインインの流れをたどります。Cookie がまだ無い、削除された、期限が切れた、の3つの状態です。その状態で呼ばれる API はすべて公開が必要です。よくある例を挙げます。",[390,391,392,396,399,402],"ul",{},[393,394,395],"li",{},"ID トークンをセッション Cookie に交換するルート",[393,397,398],{},"サインアウト（期限切れのセッションでも動く必要があります）",[393,400,401],{},"生存確認や準備完了の確認",[393,403,404],{},"ページがサーバーでの描画中に読み込むデータ（ページを開けば誰でも読めるもの）",[248,406,407,408,411,412,415,416,418],{},"他のサーバーから届く Webhook は事情が違います。",[260,409,410],{},"Origin"," を送らないので、同一オリジンの確認で POST が拒否されます。",[260,413,414],{},"server\u002Fapi"," の外に置いてください。",[378,417,201],{"href":200}," を参照してください。",[383,420,421],{"id":421},"公開ルートの決まり",[390,423,424,427,430],{},[393,425,426],{},"ルート自身で必要な確認を行います。ID トークンやボット対策などです。",[393,428,429],{},"公開してよいデータだけを返します。",[393,431,432],{},"公開ルートは小さく保ちます。公開するキャッチオールから保護する処理へ振り分けないでください。公開の印は、そのハンドラーひとつに付くものです。",[248,434,435],{},"この設定はパスではなくハンドラーに付きます。パスの正規化が変わっても、別のルートに移ることはありません。",[437,438,439],"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 .skxfh, html code.shiki .skxfh{--shiki-light:#E53935;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .syTEX, html code.shiki .syTEX{--shiki-light:#FF5370;--shiki-default:#005CC5;--shiki-dark:#79B8FF}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":258,"searchDepth":70,"depth":70,"links":441},[442,443],{"id":385,"depth":70,"text":385},{"id":421,"depth":70,"text":421},"生存確認やサインインの入口など、利用者のいないルート。","md",{},{"title":31,"description":444},"gGylCu4apaPdhADP5_h9770UkdKZX_un3am296NINYE",[450,452],{"title":27,"path":28,"stem":29,"description":451,"children":-1},"defineBffHandler を忘れたルートを、ビルドがどう見つけるか。",{"title":35,"path":36,"stem":37,"description":453,"children":-1},"Cookie を使う更新で、クロスサイトリクエストフォージェリをどう止めるか。",1796451485116,"a99f93bd-e267-45a7-90df-9194cd77468d"]