[{"data":1,"prerenderedAt":536},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fbase-url":3},{"id":4,"title":5,"body":6,"description":520,"extension":526,"frontmatter":527,"heading":5,"meta":528,"navigation":529,"order":530,"path":531,"seo":532,"sitemap":533,"source":4,"stem":534,"__hash__":535},"extensions\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fbase-url.md","Set the base URL",{"type":7,"value":8,"toc":519},"minimark",[9,18,34,39,53,239,250,254,261,320,326,438,443,507],[10,11,12,13,17],"p",{},"Set ",[14,15,16],"code",{},"baseURL"," on the client plugin or on the generated client.",[19,20,22,23,26,27,30,31,33],"blockquote",{"as":21},"note","OpenAPI server URLs do not configure the client automatically. The ",[14,24,25],{},"server"," option of ",[14,28,29],{},"adapterOas"," only sets document metadata. It does not set ",[14,32,16],{},".",[35,36,38],"h2",{"id":37},"use-the-baseurl-option","Use the baseURL option",[10,40,41,42,44,45,48,49,52],{},"Pass ",[14,43,16],{}," to ",[14,46,47],{},"pluginAxios"," to set the generated default. Add ",[14,50,51],{},"pluginTs"," for the operation types.",[54,55,60],"pre",{"language":56,"filename":57,"code":58,"class":59},"typescript","kubb.config.ts","import { defineConfig } from 'kubb\u002Fconfig'\nimport { pluginTs } from '@kubb\u002Fplugin-ts'\nimport { pluginAxios } from '@kubb\u002Fplugin-axios'\n\nexport default defineConfig({\n  input: '.\u002FpetStore.yaml',\n  output: { path: '.\u002Fsrc\u002Fgen' },\n  plugins: [\n    pluginTs(),\n    pluginAxios({ baseURL: 'https:\u002F\u002Flocalhost:8080\u002Fapi\u002Fv1' }),\n  ],\n})","highlights",[14,61,63,90,91,90,107,90,123,90,125,90,140,90,157,90,181,90,193,90,205,90,226,90,235],{"class":62},"language-typescript",[64,65,68,72,76,80,83,86],"span",{"class":66,"style":67},"line","display: inline",[64,69,71],{"style":70},"color:#d73a49;--hls-dark:#f97583","import ",[64,73,75],{"style":74},"color:#005cc5;--hls-dark:#79b8ff","{ ",[64,77,79],{"style":78},"color:#24292e;--hls-dark:#e1e4e8","defineConfig ",[64,81,82],{"style":74},"} ",[64,84,85],{"style":70},"from ",[64,87,89],{"style":88},"color:#032f62;--hls-dark:#9ecbff","'kubb\u002Fconfig'","\n",[64,92,93,95,97,100,102,104],{"class":66,"style":67},[64,94,71],{"style":70},[64,96,75],{"style":74},[64,98,99],{"style":78},"pluginTs ",[64,101,82],{"style":74},[64,103,85],{"style":70},[64,105,106],{"style":88},"'@kubb\u002Fplugin-ts'",[64,108,109,111,113,116,118,120],{"class":66,"style":67},[64,110,71],{"style":70},[64,112,75],{"style":74},[64,114,115],{"style":78},"pluginAxios ",[64,117,82],{"style":74},[64,119,85],{"style":70},[64,121,122],{"style":88},"'@kubb\u002Fplugin-axios'",[64,124],{"class":66,"style":67},[64,126,127,130,133,137],{"class":66,"style":67},[64,128,129],{"style":70},"export ",[64,131,132],{"style":70},"default ",[64,134,136],{"style":135},"color:#6f42c1;--hls-dark:#b392f0","defineConfig",[64,138,139],{"style":74},"({",[64,141,142,145,148,151,154],{"class":66,"style":67},[64,143,144],{"style":74},"  ",[64,146,147],{"style":74},"input",[64,149,150],{"style":70},": ",[64,152,153],{"style":88},"'.\u002FpetStore.yaml'",[64,155,156],{"style":70},",",[64,158,159,161,164,166,168,171,173,176,179],{"class":66,"style":67},[64,160,144],{"style":70},[64,162,163],{"style":74},"output",[64,165,150],{"style":70},[64,167,75],{"style":74},[64,169,170],{"style":74},"path",[64,172,150],{"style":70},[64,174,175],{"style":88},"'.\u002Fsrc\u002Fgen' ",[64,177,178],{"style":74},"}",[64,180,156],{"style":70},[64,182,183,185,188,190],{"class":66,"style":67},[64,184,144],{"style":70},[64,186,187],{"style":74},"plugins",[64,189,150],{"style":70},[64,191,192],{"style":74},"[",[64,194,195,198,200,203],{"class":66,"style":67},[64,196,197],{"style":74},"    ",[64,199,51],{"style":135},[64,201,202],{"style":74},"()",[64,204,156],{"style":70},[64,206,207,209,211,214,216,218,221,224],{"class":66,"style":67},[64,208,197],{"style":70},[64,210,47],{"style":135},[64,212,213],{"style":74},"({ ",[64,215,16],{"style":74},[64,217,150],{"style":70},[64,219,220],{"style":88},"'https:\u002F\u002Flocalhost:8080\u002Fapi\u002Fv1' ",[64,222,223],{"style":74},"})",[64,225,156],{"style":70},[64,227,228,230,233],{"class":66,"style":67},[64,229,144],{"style":70},[64,231,232],{"style":74},"]",[64,234,156],{"style":70},[64,236,237],{"class":66,"style":67},[64,238,223],{"style":74},[10,240,241,242,245,246,249],{},"A value containing a ",[14,243,244],{},"${...}"," interpolation stays dynamic. The plugin emits it as a template literal in the generated client config, so ",[14,247,248],{},"baseURL: '${process.env.API_URL}'"," reads the environment variable when the app runs instead of baking in the build-time value.",[35,251,253],{"id":252},"set-it-at-runtime","Set it at runtime",[10,255,256,257,260],{},"Use ",[14,258,259],{},"client.setConfig"," to configure all operations at startup:",[54,262,264],{"language":56,"code":263,"class":59},"import { client } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\nclient.setConfig({ baseURL: import.meta.env.VITE_API_URL })",[14,265,266,90,282,90,284],{"class":62},[64,267,268,270,272,275,277,279],{"class":66,"style":67},[64,269,71],{"style":70},[64,271,75],{"style":74},[64,273,274],{"style":78},"client ",[64,276,82],{"style":74},[64,278,85],{"style":70},[64,280,281],{"style":88},"'.\u002Fgen\u002F.kubb\u002Fclient'",[64,283],{"class":66,"style":67},[64,285,286,289,291,294,296,298,300,303,305,308,310,313,315,318],{"class":66,"style":67},[64,287,288],{"style":78},"client",[64,290,33],{"style":70},[64,292,293],{"style":135},"setConfig",[64,295,213],{"style":74},[64,297,16],{"style":74},[64,299,150],{"style":70},[64,301,302],{"style":70},"import",[64,304,33],{"style":70},[64,306,307],{"style":74},"meta",[64,309,33],{"style":70},[64,311,312],{"style":74},"env",[64,314,33],{"style":70},[64,316,317],{"style":74},"VITE_API_URL ",[64,319,223],{"style":74},[10,321,256,322,325],{},[14,323,324],{},"createClient"," for an isolated client, then pass it to an operation:",[54,327,329],{"language":56,"code":328,"class":59},"import { createClient } from '.\u002Fgen\u002F.kubb\u002Fclient'\nimport { getPetById } from '.\u002Fgen\u002Fclients\u002FgetPetById'\n\nconst staging = createClient({ baseURL: 'https:\u002F\u002Fstaging.petstore.swagger.io\u002Fv2' })\n\nconst { data } = await getPetById({ path: { petId: 1 }, client: staging })",[14,330,331,90,346,90,362,90,364,90,388,90,390],{"class":62},[64,332,333,335,337,340,342,344],{"class":66,"style":67},[64,334,71],{"style":70},[64,336,75],{"style":74},[64,338,339],{"style":78},"createClient ",[64,341,82],{"style":74},[64,343,85],{"style":70},[64,345,281],{"style":88},[64,347,348,350,352,355,357,359],{"class":66,"style":67},[64,349,71],{"style":70},[64,351,75],{"style":74},[64,353,354],{"style":78},"getPetById ",[64,356,82],{"style":74},[64,358,85],{"style":70},[64,360,361],{"style":88},"'.\u002Fgen\u002Fclients\u002FgetPetById'",[64,363],{"class":66,"style":67},[64,365,366,369,372,375,377,379,381,383,386],{"class":66,"style":67},[64,367,368],{"style":70},"const ",[64,370,371],{"style":78},"staging ",[64,373,374],{"style":70},"= ",[64,376,324],{"style":135},[64,378,213],{"style":74},[64,380,16],{"style":74},[64,382,150],{"style":70},[64,384,385],{"style":88},"'https:\u002F\u002Fstaging.petstore.swagger.io\u002Fv2' ",[64,387,223],{"style":74},[64,389],{"class":66,"style":67},[64,391,392,394,396,399,401,403,406,409,411,413,415,417,420,422,425,427,430,432,434,436],{"class":66,"style":67},[64,393,368],{"style":70},[64,395,75],{"style":74},[64,397,398],{"style":78},"data ",[64,400,82],{"style":74},[64,402,374],{"style":70},[64,404,405],{"style":70},"await ",[64,407,408],{"style":135},"getPetById",[64,410,213],{"style":74},[64,412,170],{"style":74},[64,414,150],{"style":70},[64,416,75],{"style":74},[64,418,419],{"style":74},"petId",[64,421,150],{"style":70},[64,423,424],{"style":74},"1 ",[64,426,178],{"style":74},[64,428,429],{"style":70},", ",[64,431,288],{"style":74},[64,433,150],{"style":70},[64,435,371],{"style":78},[64,437,223],{"style":74},[10,439,41,440,442],{},[14,441,16],{}," on a single call to override the client for that one request:",[54,444,446],{"language":56,"code":445,"class":59},"import { getPetById } from '.\u002Fgen\u002Fclients\u002FgetPetById'\n\nconst { data } = await getPetById({ path: { petId: 1 }, baseURL: 'https:\u002F\u002Flocalhost:3000' })",[14,447,448,90,462,90,464],{"class":62},[64,449,450,452,454,456,458,460],{"class":66,"style":67},[64,451,71],{"style":70},[64,453,75],{"style":74},[64,455,354],{"style":78},[64,457,82],{"style":74},[64,459,85],{"style":70},[64,461,361],{"style":88},[64,463],{"class":66,"style":67},[64,465,466,468,470,472,474,476,478,480,482,484,486,488,490,492,494,496,498,500,502,505],{"class":66,"style":67},[64,467,368],{"style":70},[64,469,75],{"style":74},[64,471,398],{"style":78},[64,473,82],{"style":74},[64,475,374],{"style":70},[64,477,405],{"style":70},[64,479,408],{"style":135},[64,481,213],{"style":74},[64,483,170],{"style":74},[64,485,150],{"style":70},[64,487,75],{"style":74},[64,489,419],{"style":74},[64,491,150],{"style":70},[64,493,424],{"style":74},[64,495,178],{"style":74},[64,497,429],{"style":70},[64,499,16],{"style":74},[64,501,150],{"style":70},[64,503,504],{"style":88},"'https:\u002F\u002Flocalhost:3000' ",[64,506,223],{"style":74},[10,508,509,510,512,513,515,516,518],{},"A ",[14,511,16],{}," set on the call wins over ",[14,514,324],{},", which wins over ",[14,517,293],{},", which wins over the build-time value.",{"title":520,"searchDepth":521,"depth":521,"links":522},"",5,[523,525],{"id":37,"depth":524,"text":38},2,{"id":252,"depth":524,"text":253},"md",{},{},true,null,"\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fbase-url",{"title":5},{"loc":531},"extensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fbase-url","-zgGveOw3hW3sOOqO6wvwbLZUdJe8Y_4ficsbzA2gBM",1792931649222]