[{"data":1,"prerenderedAt":1680},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-fetch\u002Fguides\u002Fconfigure-requests":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":1679,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-fetch\u002Fguides\u002Fconfigure-requests.md",{},"Configure requests",{"type":8,"value":9,"toc":1663},"minimark",[10,14,19,31,116,147,378,382,385,458,473,485,489,504,592,598,739,750,761,765,771,850,1197,1242,1254,1383,1390,1397,1401,1405,1432,1448,1451,1461,1576,1579,1592,1601,1640,1643,1660],[11,12,13],"p",{},"Set the base URL, credentials, shared headers, and interceptors on the generated client, for every call or for one.",[15,16,18],"h2",{"id":17},"where-settings-apply","Where settings apply",[11,20,21,22,26,27,30],{},"Every generated function sends through the shared ",[23,24,25],"code",{},"client"," from ",[23,28,29],{},".kubb\u002Fclient.ts",", unless a call passes its own:",[32,33,34,50],"table",{},[35,36,37],"thead",{},[38,39,40,44,47],"tr",{},[41,42,43],"th",{},"Scope",[41,45,46],{},"How",[41,48,49],{},"Effect",[51,52,53,79,92,105],"tbody",{},[38,54,55,59,64],{},[56,57,58],"td",{},"Every call",[56,60,61],{},[23,62,63],{},"client.setConfig({ ... })",[56,65,66,67,70,71,74,75,78],{},"Merges into the shared config. ",[23,68,69],{},"headers",", ",[23,72,73],{},"mediaTypes",", and ",[23,76,77],{},"serializer"," merge per key.",[38,80,81,84,89],{},[56,82,83],{},"A separate client",[56,85,86],{},[23,87,88],{},"createClient({ ... })",[56,90,91],{},"Copies the shared config at creation, without its interceptors.",[38,93,94,97,102],{},[56,95,96],{},"A child client",[56,98,99],{},[23,100,101],{},"client.extend({ ... })",[56,103,104],{},"Copies the shared config and runs the parent's interceptors first.",[38,106,107,110,113],{},[56,108,109],{},"One call",[56,111,112],{},"The same key on the call",[56,114,115],{},"Wins over the client for that call.",[11,117,118,119,70,122,70,124,70,127,70,130,70,133,70,136,70,138,70,140,74,143,146],{},"The client takes ",[23,120,121],{},"baseURL",[23,123,69],{},[23,125,126],{},"auth",[23,128,129],{},"credentials",[23,131,132],{},"options",[23,134,135],{},"transport",[23,137,77],{},[23,139,73],{},[23,141,142],{},"validate",[23,144,145],{},"onValidationError",":",[148,149,153],"pre",{"language":150,"code":151,"class":152},"typescript","import { client, createClient } from '.\u002Fgen\u002F.kubb\u002Fclient'\nimport { getPetById } from '.\u002Fgen\u002Fclients\u002FgetPetById'\n\nclient.setConfig({ baseURL: import.meta.env.VITE_API_URL, headers: { 'X-Client': 'web' } })\n\nconst tenant = createClient({ baseURL: 'https:\u002F\u002Ftenant.example.com', auth: () => tenantToken })\nawait getPetById({ path: { petId: 1 }, client: tenant })\n\nawait getPetById({ path: { petId: 1 }, baseURL: 'http:\u002F\u002Flocalhost:3000' })","highlights",[23,154,156,187,188,187,204,187,206,187,262,187,264,187,305,187,343,187,345],{"class":155},"language-typescript",[157,158,161,165,169,172,174,177,180,183],"span",{"class":159,"style":160},"line","display: inline",[157,162,164],{"style":163},"color:#d73a49;--hls-dark:#f97583","import ",[157,166,168],{"style":167},"color:#005cc5;--hls-dark:#79b8ff","{ ",[157,170,25],{"style":171},"color:#24292e;--hls-dark:#e1e4e8",[157,173,70],{"style":163},[157,175,176],{"style":171},"createClient ",[157,178,179],{"style":167},"} ",[157,181,182],{"style":163},"from ",[157,184,186],{"style":185},"color:#032f62;--hls-dark:#9ecbff","'.\u002Fgen\u002F.kubb\u002Fclient'","\n",[157,189,190,192,194,197,199,201],{"class":159,"style":160},[157,191,164],{"style":163},[157,193,168],{"style":167},[157,195,196],{"style":171},"getPetById ",[157,198,179],{"style":167},[157,200,182],{"style":163},[157,202,203],{"style":185},"'.\u002Fgen\u002Fclients\u002FgetPetById'",[157,205],{"class":159,"style":160},[157,207,208,210,213,217,220,222,225,228,230,233,235,238,240,243,245,247,249,251,254,256,259],{"class":159,"style":160},[157,209,25],{"style":171},[157,211,212],{"style":163},".",[157,214,216],{"style":215},"color:#6f42c1;--hls-dark:#b392f0","setConfig",[157,218,219],{"style":167},"({ ",[157,221,121],{"style":167},[157,223,224],{"style":163},": ",[157,226,227],{"style":163},"import",[157,229,212],{"style":163},[157,231,232],{"style":167},"meta",[157,234,212],{"style":163},[157,236,237],{"style":167},"env",[157,239,212],{"style":163},[157,241,242],{"style":167},"VITE_API_URL",[157,244,70],{"style":163},[157,246,69],{"style":167},[157,248,224],{"style":163},[157,250,168],{"style":167},[157,252,253],{"style":185},"'X-Client'",[157,255,224],{"style":163},[157,257,258],{"style":185},"'web' ",[157,260,261],{"style":167},"} })",[157,263],{"class":159,"style":160},[157,265,266,269,272,275,278,280,282,284,287,289,291,293,296,299,302],{"class":159,"style":160},[157,267,268],{"style":163},"const ",[157,270,271],{"style":171},"tenant ",[157,273,274],{"style":163},"= ",[157,276,277],{"style":215},"createClient",[157,279,219],{"style":167},[157,281,121],{"style":167},[157,283,224],{"style":163},[157,285,286],{"style":185},"'https:\u002F\u002Ftenant.example.com'",[157,288,70],{"style":163},[157,290,126],{"style":167},[157,292,224],{"style":163},[157,294,295],{"style":167},"() ",[157,297,298],{"style":163},"=> ",[157,300,301],{"style":171},"tenantToken ",[157,303,304],{"style":167},"})",[157,306,307,310,313,315,318,320,322,325,327,330,333,335,337,339,341],{"class":159,"style":160},[157,308,309],{"style":163},"await ",[157,311,312],{"style":215},"getPetById",[157,314,219],{"style":167},[157,316,317],{"style":167},"path",[157,319,224],{"style":163},[157,321,168],{"style":167},[157,323,324],{"style":167},"petId",[157,326,224],{"style":163},[157,328,329],{"style":167},"1 ",[157,331,332],{"style":167},"}",[157,334,70],{"style":163},[157,336,25],{"style":167},[157,338,224],{"style":163},[157,340,271],{"style":171},[157,342,304],{"style":167},[157,344],{"class":159,"style":160},[157,346,347,349,351,353,355,357,359,361,363,365,367,369,371,373,376],{"class":159,"style":160},[157,348,309],{"style":163},[157,350,312],{"style":215},[157,352,219],{"style":167},[157,354,317],{"style":167},[157,356,224],{"style":163},[157,358,168],{"style":167},[157,360,324],{"style":167},[157,362,224],{"style":163},[157,364,329],{"style":167},[157,366,332],{"style":167},[157,368,70],{"style":163},[157,370,121],{"style":167},[157,372,224],{"style":163},[157,374,375],{"style":185},"'http:\u002F\u002Flocalhost:3000' ",[157,377,304],{"style":167},[15,379,381],{"id":380},"set-the-base-url","Set the base URL",[11,383,384],{},"A call uses the first base URL it finds:",[32,386,387,397],{},[35,388,389],{},[38,390,391,394],{},[41,392,393],{},"Order",[41,395,396],{},"Source",[51,398,399,409,423,433,443],{},[38,400,401,404],{},[56,402,403],{},"1",[56,405,406,408],{},[23,407,121],{}," on the call.",[38,410,411,414],{},[56,412,413],{},"2",[56,415,416,417,420,421,212],{},"The operation's own ",[23,418,419],{},"servers",", then its path's ",[23,422,419],{},[38,424,425,428],{},[56,426,427],{},"3",[56,429,430,431,212],{},"The client passed as ",[23,432,25],{},[38,434,435,438],{},[56,436,437],{},"4",[56,439,440,212],{},[23,441,442],{},"client.setConfig({ baseURL })",[38,444,445,448],{},[56,446,447],{},"5",[56,449,450,451,457],{},"The plugin's ",[452,453,455],"a",{"href":454},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-fetch\u002Foptions#baseurl",[23,456,121],{}," option.",[459,460,462,463,465,466,469,470,212],"blockquote",{"as":461},"note","The spec's top-level ",[23,464,419],{}," URL is never used, even with the ",[23,467,468],{},"server"," option of ",[23,471,472],{},"adapterOas",[11,474,475,476,480,481,212],{},"See ",[452,477,479],{"href":478},"#which-server-a-call-picks","Which server a call picks"," and ",[452,482,484],{"href":483},"#named-servers","Named servers",[15,486,488],{"id":487},"authenticate-requests","Authenticate requests",[11,490,491,492,494,495,499,500,503],{},"Set ",[23,493,126],{}," to a token, or to a sync or async function that gets each ",[452,496,498],{"href":497},"https:\u002F\u002Fspec.openapis.org\u002Foas\u002Fv3.1.0#security-scheme-object","security scheme"," of the call. It returns the token, or ",[23,501,502],{},"undefined"," to skip the scheme:",[148,505,507],{"language":150,"code":506,"class":152},"client.setConfig({\n  auth: (auth) => (auth.type === 'apiKey' ? apiKey : localStorage.getItem('token') ?? undefined),\n})",[23,508,509,187,520,187,588],{"class":155},[157,510,511,513,515,517],{"class":159,"style":160},[157,512,25],{"style":171},[157,514,212],{"style":163},[157,516,216],{"style":215},[157,518,519],{"style":167},"({",[157,521,522,525,527,529,532,534,537,539,541,543,545,548,551,554,557,560,562,565,567,570,572,575,577,580,582,585],{"class":159,"style":160},[157,523,524],{"style":167},"  ",[157,526,126],{"style":167},[157,528,224],{"style":163},[157,530,531],{"style":167},"(",[157,533,126],{"style":171},[157,535,536],{"style":167},") ",[157,538,298],{"style":163},[157,540,531],{"style":167},[157,542,126],{"style":171},[157,544,212],{"style":163},[157,546,547],{"style":167},"type ",[157,549,550],{"style":163},"=== ",[157,552,553],{"style":185},"'apiKey' ",[157,555,556],{"style":163},"? ",[157,558,559],{"style":171},"apiKey ",[157,561,224],{"style":163},[157,563,564],{"style":171},"localStorage",[157,566,212],{"style":163},[157,568,569],{"style":215},"getItem",[157,571,531],{"style":167},[157,573,574],{"style":185},"'token'",[157,576,536],{"style":167},[157,578,579],{"style":163},"?? ",[157,581,502],{"style":167},[157,583,584],{"style":167},")",[157,586,587],{"style":163},",",[157,589,590],{"class":159,"style":160},[157,591,304],{"style":167},[11,593,594,595,597],{},"By default, ",[23,596,126],{}," adds no credentials. The scheme decides where the token goes:",[32,599,600,615],{},[35,601,602],{},[38,603,604,607,612],{},[41,605,606],{},"Scheme in the spec",[41,608,609,611],{},[23,610,126],{}," gets",[41,613,614],{},"The token goes to",[51,616,617,635,652,671,688,707,723],{},[38,618,619,625,630],{},[56,620,621,624],{},[23,622,623],{},"http"," bearer",[56,626,627],{},[23,628,629],{},"{ type: 'http', scheme: 'bearer' }",[56,631,632],{},[23,633,634],{},"Authorization: Bearer \u003Ctoken>",[38,636,637,642,647],{},[56,638,639,641],{},[23,640,623],{}," basic",[56,643,644],{},[23,645,646],{},"{ type: 'http', scheme: 'basic' }",[56,648,649],{},[23,650,651],{},"Authorization: Basic \u003Cbase64>",[38,653,654,660,665],{},[56,655,656,659],{},[23,657,658],{},"apiKey"," in header",[56,661,662],{},[23,663,664],{},"{ type: 'apiKey', name, in: 'header' }",[56,666,667,668],{},"the header named ",[23,669,670],{},"name",[38,672,673,678,683],{},[56,674,675,677],{},[23,676,658],{}," in query",[56,679,680],{},[23,681,682],{},"{ type: 'apiKey', name, in: 'query' }",[56,684,685,686],{},"the query parameter ",[23,687,670],{},[38,689,690,695,700],{},[56,691,692,694],{},[23,693,658],{}," in cookie",[56,696,697],{},[23,698,699],{},"{ type: 'apiKey', name, in: 'cookie' }",[56,701,702,703,706],{},"the ",[23,704,705],{},"Cookie"," header",[38,708,709,714,719],{},[56,710,711],{},[23,712,713],{},"oauth2",[56,715,716],{},[23,717,718],{},"{ type: 'oauth2', scopes, flows }",[56,720,721],{},[23,722,634],{},[38,724,725,730,735],{},[56,726,727],{},[23,728,729],{},"openIdConnect",[56,731,732],{},[23,733,734],{},"{ type: 'openIdConnect', scopes, url }",[56,736,737],{},[23,738,634],{},[459,740,741,742,745,746,749],{"as":461},"For basic auth, return the raw ",[23,743,744],{},"username:password",". The runtime base64-encodes it and adds the ",[23,747,748],{},"Basic"," prefix.",[11,751,752,753,480,757,212],{},"For a credential that no security scheme describes, such as a request signature, add a request interceptor. See ",[452,754,756],{"href":755},"#several-security-schemes","Several security schemes",[452,758,760],{"href":759},"#mutual-tls","Mutual TLS",[15,762,764],{"id":763},"add-interceptors","Add interceptors",[11,766,767,770],{},[23,768,769],{},"client.interceptors"," has three stacks. Each handler gets the value the one before it returned:",[32,772,773,789],{},[35,774,775],{},[38,776,777,780,783,786],{},[41,778,779],{},"Stack",[41,781,782],{},"Runs",[41,784,785],{},"Gets",[41,787,788],{},"Returns",[51,790,791,809,827],{},[38,792,793,798,801,806],{},[56,794,795],{},[23,796,797],{},"request",[56,799,800],{},"After the URL, body, and auth are built, before the send.",[56,802,803],{},[23,804,805],{},"ResolvedRequest",[56,807,808],{},"The request.",[38,810,811,816,819,824],{},[56,812,813],{},[23,814,815],{},"response",[56,817,818],{},"After the body is decoded, before the status check and validator.",[56,820,821],{},[23,822,823],{},"DecodedResponse",[56,825,826],{},"The result.",[38,828,829,834,844,847],{},[56,830,831],{},[23,832,833],{},"error",[56,835,836,837,840,841,212],{},"On any failure: ",[23,838,839],{},"ResponseError",", network error, abort, ",[23,842,843],{},"ParseError",[56,845,846],{},"The error",[56,848,849],{},"Another error to throw, or nothing to keep it.",[851,852,853,933,1024],"code-group",{},[148,854,856],{"language":150,"filename":797,"code":855,"class":152},"client.interceptors.request.use((request) => {\n  request.headers['X-Request-ID'] = crypto.randomUUID()\n  return request\n})",[23,857,858,187,888,187,920,187,929],{"class":155},[157,859,860,862,864,867,869,871,873,876,879,881,883,885],{"class":159,"style":160},[157,861,25],{"style":171},[157,863,212],{"style":163},[157,865,866],{"style":167},"interceptors",[157,868,212],{"style":163},[157,870,797],{"style":167},[157,872,212],{"style":163},[157,874,875],{"style":215},"use",[157,877,878],{"style":167},"((",[157,880,797],{"style":171},[157,882,536],{"style":167},[157,884,298],{"style":163},[157,886,887],{"style":167},"{",[157,889,890,892,894,896,898,901,904,907,909,912,914,917],{"class":159,"style":160},[157,891,524],{"style":167},[157,893,797],{"style":171},[157,895,212],{"style":163},[157,897,69],{"style":167},[157,899,900],{"style":167},"[",[157,902,903],{"style":185},"'X-Request-ID'",[157,905,906],{"style":167},"] ",[157,908,274],{"style":163},[157,910,911],{"style":171},"crypto",[157,913,212],{"style":163},[157,915,916],{"style":215},"randomUUID",[157,918,919],{"style":167},"()",[157,921,922,924,927],{"class":159,"style":160},[157,923,524],{"style":167},[157,925,926],{"style":163},"return ",[157,928,797],{"style":171},[157,930,931],{"class":159,"style":160},[157,932,304],{"style":167},[148,934,936],{"language":150,"filename":815,"code":935,"class":152},"client.interceptors.response.use((result) => {\n  console.info(`${result.status} ${result.contentType}`)\n  return result\n})",[23,937,938,187,965,187,1012,187,1020],{"class":155},[157,939,940,942,944,946,948,950,952,954,956,959,961,963],{"class":159,"style":160},[157,941,25],{"style":171},[157,943,212],{"style":163},[157,945,866],{"style":167},[157,947,212],{"style":163},[157,949,815],{"style":167},[157,951,212],{"style":163},[157,953,875],{"style":215},[157,955,878],{"style":167},[157,957,958],{"style":171},"result",[157,960,536],{"style":167},[157,962,298],{"style":163},[157,964,887],{"style":167},[157,966,967,969,972,974,977,979,982,985,987,989,992,994,997,999,1001,1003,1006,1008,1010],{"class":159,"style":160},[157,968,524],{"style":167},[157,970,971],{"style":171},"console",[157,973,212],{"style":163},[157,975,976],{"style":215},"info",[157,978,531],{"style":167},[157,980,981],{"style":185},"`",[157,983,984],{"style":171},"${",[157,986,958],{"style":171},[157,988,212],{"style":163},[157,990,991],{"style":167},"status",[157,993,332],{"style":171},[157,995,996],{"style":185}," ",[157,998,984],{"style":171},[157,1000,958],{"style":171},[157,1002,212],{"style":163},[157,1004,1005],{"style":167},"contentType",[157,1007,332],{"style":171},[157,1009,981],{"style":185},[157,1011,584],{"style":167},[157,1013,1014,1016,1018],{"class":159,"style":160},[157,1015,524],{"style":167},[157,1017,926],{"style":163},[157,1019,958],{"style":171},[157,1021,1022],{"class":159,"style":160},[157,1023,304],{"style":167},[148,1025,1027],{"language":150,"filename":833,"code":1026,"class":152},"import { client, ResponseError } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\nclass NotFoundError extends Error {}\n\nclient.interceptors.error.use((error) => {\n  if (ResponseError.is(error) && error.status === 401) scheduleTokenRefresh()\n  if (ResponseError.is(error) && error.status === 404) return new NotFoundError(error.message)\n})",[23,1028,1029,187,1048,187,1050,187,1067,187,1069,187,1095,187,1139,187,1193],{"class":155},[157,1030,1031,1033,1035,1037,1039,1042,1044,1046],{"class":159,"style":160},[157,1032,164],{"style":163},[157,1034,168],{"style":167},[157,1036,25],{"style":171},[157,1038,70],{"style":163},[157,1040,1041],{"style":215},"ResponseError ",[157,1043,179],{"style":167},[157,1045,182],{"style":163},[157,1047,186],{"style":185},[157,1049],{"class":159,"style":160},[157,1051,1052,1055,1058,1061,1064],{"class":159,"style":160},[157,1053,1054],{"style":163},"class ",[157,1056,1057],{"style":215},"NotFoundError ",[157,1059,1060],{"style":163},"extends ",[157,1062,1063],{"style":215},"Error ",[157,1065,1066],{"style":167},"{}",[157,1068],{"class":159,"style":160},[157,1070,1071,1073,1075,1077,1079,1081,1083,1085,1087,1089,1091,1093],{"class":159,"style":160},[157,1072,25],{"style":171},[157,1074,212],{"style":163},[157,1076,866],{"style":167},[157,1078,212],{"style":163},[157,1080,833],{"style":167},[157,1082,212],{"style":163},[157,1084,875],{"style":215},[157,1086,878],{"style":167},[157,1088,833],{"style":171},[157,1090,536],{"style":167},[157,1092,298],{"style":163},[157,1094,887],{"style":167},[157,1096,1097,1099,1102,1104,1106,1108,1111,1113,1115,1117,1120,1122,1124,1127,1129,1132,1134,1137],{"class":159,"style":160},[157,1098,524],{"style":167},[157,1100,1101],{"style":163},"if ",[157,1103,531],{"style":167},[157,1105,839],{"style":215},[157,1107,212],{"style":163},[157,1109,1110],{"style":215},"is",[157,1112,531],{"style":167},[157,1114,833],{"style":171},[157,1116,536],{"style":167},[157,1118,1119],{"style":163},"&& ",[157,1121,833],{"style":171},[157,1123,212],{"style":163},[157,1125,1126],{"style":167},"status ",[157,1128,550],{"style":163},[157,1130,1131],{"style":167},"401",[157,1133,536],{"style":167},[157,1135,1136],{"style":215},"scheduleTokenRefresh",[157,1138,919],{"style":167},[157,1140,1141,1143,1145,1147,1149,1151,1153,1155,1157,1159,1161,1163,1165,1167,1169,1172,1174,1176,1179,1182,1184,1186,1188,1191],{"class":159,"style":160},[157,1142,524],{"style":167},[157,1144,1101],{"style":163},[157,1146,531],{"style":167},[157,1148,839],{"style":215},[157,1150,212],{"style":163},[157,1152,1110],{"style":215},[157,1154,531],{"style":167},[157,1156,833],{"style":171},[157,1158,536],{"style":167},[157,1160,1119],{"style":163},[157,1162,833],{"style":171},[157,1164,212],{"style":163},[157,1166,1126],{"style":167},[157,1168,550],{"style":163},[157,1170,1171],{"style":167},"404",[157,1173,536],{"style":167},[157,1175,926],{"style":163},[157,1177,1178],{"style":163},"new ",[157,1180,1181],{"style":215},"NotFoundError",[157,1183,531],{"style":167},[157,1185,833],{"style":171},[157,1187,212],{"style":163},[157,1189,1190],{"style":167},"message",[157,1192,584],{"style":167},[157,1194,1195],{"class":159,"style":160},[157,1196,304],{"style":167},[11,1198,1199,1201,1202,70,1205,70,1208,70,1210,70,1213,70,1216,70,1218,74,1220,1223,1224,1201,1226,70,1229,70,1231,70,1234,70,1236,70,1238,74,1240,212],{},[23,1200,805],{}," has ",[23,1203,1204],{},"url",[23,1206,1207],{},"method",[23,1209,69],{},[23,1211,1212],{},"body",[23,1214,1215],{},"signal",[23,1217,129],{},[23,1219,132],{},[23,1221,1222],{},"stream",". ",[23,1225,823],{},[23,1227,1228],{},"data",[23,1230,991],{},[23,1232,1233],{},"statusText",[23,1235,69],{},[23,1237,1005],{},[23,1239,797],{},[23,1241,815],{},[11,1243,1244,1245,1247,1248,480,1251,146],{},"Handlers run in the order you register them. ",[23,1246,875],{}," returns an id for ",[23,1249,1250],{},"eject",[23,1252,1253],{},"update",[148,1255,1257],{"language":150,"code":1256,"class":152},"const id = client.interceptors.request.use((request) => request)\nclient.interceptors.request.update(id, (request) => ({ ...request, headers: { ...request.headers, 'X-Trace': 'on' } }))\nclient.interceptors.request.eject(id)",[23,1258,1259,187,1294,187,1361],{"class":155},[157,1260,1261,1263,1266,1268,1270,1272,1274,1276,1278,1280,1282,1284,1286,1288,1290,1292],{"class":159,"style":160},[157,1262,268],{"style":163},[157,1264,1265],{"style":171},"id ",[157,1267,274],{"style":163},[157,1269,25],{"style":171},[157,1271,212],{"style":163},[157,1273,866],{"style":167},[157,1275,212],{"style":163},[157,1277,797],{"style":167},[157,1279,212],{"style":163},[157,1281,875],{"style":215},[157,1283,878],{"style":167},[157,1285,797],{"style":171},[157,1287,536],{"style":167},[157,1289,298],{"style":163},[157,1291,797],{"style":171},[157,1293,584],{"style":167},[157,1295,1296,1298,1300,1302,1304,1306,1308,1310,1312,1315,1317,1319,1321,1323,1325,1327,1330,1332,1334,1336,1338,1340,1342,1344,1346,1348,1350,1353,1355,1358],{"class":159,"style":160},[157,1297,25],{"style":171},[157,1299,212],{"style":163},[157,1301,866],{"style":167},[157,1303,212],{"style":163},[157,1305,797],{"style":167},[157,1307,212],{"style":163},[157,1309,1253],{"style":215},[157,1311,531],{"style":167},[157,1313,1314],{"style":171},"id",[157,1316,70],{"style":163},[157,1318,531],{"style":167},[157,1320,797],{"style":171},[157,1322,536],{"style":167},[157,1324,298],{"style":163},[157,1326,219],{"style":167},[157,1328,1329],{"style":163},"...",[157,1331,797],{"style":171},[157,1333,70],{"style":163},[157,1335,69],{"style":167},[157,1337,224],{"style":163},[157,1339,168],{"style":167},[157,1341,1329],{"style":163},[157,1343,797],{"style":171},[157,1345,212],{"style":163},[157,1347,69],{"style":167},[157,1349,70],{"style":163},[157,1351,1352],{"style":185},"'X-Trace'",[157,1354,224],{"style":163},[157,1356,1357],{"style":185},"'on' ",[157,1359,1360],{"style":167},"} }))",[157,1362,1363,1365,1367,1369,1371,1373,1375,1377,1379,1381],{"class":159,"style":160},[157,1364,25],{"style":171},[157,1366,212],{"style":163},[157,1368,866],{"style":167},[157,1370,212],{"style":163},[157,1372,797],{"style":167},[157,1374,212],{"style":163},[157,1376,1250],{"style":215},[157,1378,531],{"style":167},[157,1380,1314],{"style":171},[157,1382,584],{"style":167},[459,1384,1385,1386,1389],{"as":461},"With ",[23,1387,1388],{},"throwOnError: false",", a non-2xx response resolves, so no error handler runs for it.",[11,1391,1392,1393,212],{},"Next, ",[452,1394,1396],{"href":1395},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-fetch\u002Fguides\u002Ftransport","use a custom transport",[15,1398,1400],{"id":1399},"less-common-cases","Less common cases",[1402,1403,479],"h3",{"id":1404},"which-server-a-call-picks",[11,1406,1407,1408,1410,1411,1417,1418,1420,1421,1424,1425,1428,1429,212],{},"When an operation or path has its own ",[23,1409,419],{},", the ",[452,1412,1414],{"href":1413},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fadapter-oas\u002Foptions#server",[23,1415,1416],{},"server.index"," of ",[23,1419,472],{}," picks the entry, falling back to the first. A relative URL such as ",[23,1422,1423],{},"\u002Fv2",", or one with ",[23,1426,1427],{},"{variable}"," placeholders, is skipped, so the call uses the next source in ",[452,1430,381],{"href":1431},"#set-the-base-url",[11,1433,450,1434,1438,1439,1442,1443,1445,1446,212],{},[452,1435,1436],{"href":454},[23,1437,121],{}," option is written into ",[23,1440,1441],{},".kubb\u002Fconfig.ts",", which ",[23,1444,29],{}," passes to ",[23,1447,216],{},[1402,1449,484],{"id":1450},"named-servers",[11,1452,1453,1454,70,1456,1458,1459,146],{},"When an OpenAPI 3.2 server has a ",[23,1455,670],{},[23,1457,29],{}," exports its URL in ",[23,1460,419],{},[851,1462,1463,1526],{},[148,1464,1468],{"language":1465,"filename":1466,"code":1467,"class":152},"yaml","petStore.yaml","servers:\n  - url: https:\u002F\u002Fapi.example.com\n    name: production\n  - url: https:\u002F\u002Fstaging.example.com\n    name: staging",[23,1469,1471,187,1477,187,1489,187,1501,187,1515],{"class":1470},"language-yaml",[157,1472,1473,1475],{"class":159,"style":160},[157,1474,419],{"style":167},[157,1476,146],{"style":163},[157,1478,1479,1482,1484,1486],{"class":159,"style":160},[157,1480,1481],{"style":163},"  - ",[157,1483,1204],{"style":167},[157,1485,224],{"style":163},[157,1487,1488],{"style":185},"https:\u002F\u002Fapi.example.com",[157,1490,1491,1494,1496,1498],{"class":159,"style":160},[157,1492,1493],{"style":185},"    ",[157,1495,670],{"style":167},[157,1497,224],{"style":163},[157,1499,1500],{"style":185},"production",[157,1502,1503,1505,1508,1510,1512],{"class":159,"style":160},[157,1504,524],{"style":185},[157,1506,1507],{"style":163},"- ",[157,1509,1204],{"style":167},[157,1511,224],{"style":163},[157,1513,1514],{"style":185},"https:\u002F\u002Fstaging.example.com",[157,1516,1517,1519,1521,1523],{"class":159,"style":160},[157,1518,1493],{"style":185},[157,1520,670],{"style":167},[157,1522,224],{"style":163},[157,1524,1525],{"style":185},"staging",[148,1527,1530],{"language":150,"filename":1528,"code":1529,"class":152},"src\u002Fapi.ts","import { client, servers } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\nclient.setConfig({ baseURL: servers.staging })",[23,1531,1532,187,1551,187,1553],{"class":155},[157,1533,1534,1536,1538,1540,1542,1545,1547,1549],{"class":159,"style":160},[157,1535,164],{"style":163},[157,1537,168],{"style":167},[157,1539,25],{"style":171},[157,1541,70],{"style":163},[157,1543,1544],{"style":171},"servers ",[157,1546,179],{"style":167},[157,1548,182],{"style":163},[157,1550,186],{"style":185},[157,1552],{"class":159,"style":160},[157,1554,1555,1557,1559,1561,1563,1565,1567,1569,1571,1574],{"class":159,"style":160},[157,1556,25],{"style":171},[157,1558,212],{"style":163},[157,1560,216],{"style":215},[157,1562,219],{"style":167},[157,1564,121],{"style":167},[157,1566,224],{"style":163},[157,1568,419],{"style":171},[157,1570,212],{"style":163},[157,1572,1573],{"style":167},"staging ",[157,1575,304],{"style":167},[1402,1577,756],{"id":1578},"several-security-schemes",[11,1580,1581,1582,1584,1585,1588,1589,1591],{},"When an operation lists several security requirements, the runtime sends the first one whose schemes all get a token. A requirement that needs an API key and a session cookie sends both. A header or query key you set yourself wins over the token. An ",[23,1583,713],{}," scheme also passes ",[23,1586,1587],{},"metadataUrl"," to ",[23,1590,126],{}," when the spec has one.",[11,1593,1594,1596,1597,1600],{},[23,1595,29],{}," exports the spec's schemes by name as ",[23,1598,1599],{},"securitySchemes",", and each generated call points at its own, with the scopes it needs:",[148,1602,1604],{"language":150,"code":1603,"class":152},"security: [{ ...securitySchemes.petstore_auth, scopes: ['write:pets'] }]",[23,1605,1606],{"class":155},[157,1607,1608,1611,1613,1616,1618,1620,1622,1625,1627,1630,1632,1634,1637],{"class":159,"style":160},[157,1609,1610],{"style":171},"security",[157,1612,224],{"style":163},[157,1614,1615],{"style":167},"[{ ",[157,1617,1329],{"style":163},[157,1619,1599],{"style":171},[157,1621,212],{"style":163},[157,1623,1624],{"style":167},"petstore_auth",[157,1626,70],{"style":163},[157,1628,1629],{"style":167},"scopes",[157,1631,224],{"style":163},[157,1633,900],{"style":167},[157,1635,1636],{"style":185},"'write:pets'",[157,1638,1639],{"style":167},"] }]",[1402,1641,760],{"id":1642},"mutual-tls",[11,1644,1645,1646,1649,1650,1652,1653,1656,1657,212],{},"When the spec has a ",[23,1647,1648],{},"mutualTLS"," scheme, ",[23,1651,1599],{}," leaves it out, because its credential is a client certificate on the connection, not on the request. In Node.js, send through an undici ",[23,1654,1655],{},"Agent"," that holds the certificate, with a ",[452,1658,1659],{"href":1395},"custom transport",[11,1661,1662],{},"In the browser, the browser picks the client certificate itself.",{"title":1664,"searchDepth":1665,"depth":1665,"links":1666},"",5,[1667,1669,1670,1671,1672],{"id":17,"depth":1668,"text":18},2,{"id":380,"depth":1668,"text":381},{"id":487,"depth":1668,"text":488},{"id":763,"depth":1668,"text":764},{"id":1399,"depth":1668,"text":1400,"children":1673},[1674,1676,1677,1678],{"id":1404,"depth":1675,"text":479},3,{"id":1450,"depth":1675,"text":484},{"id":1578,"depth":1675,"text":756},{"id":1642,"depth":1675,"text":760},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-fetch\u002Fguides\u002Fconfigure-requests",1794776437692]