1"use strict";(self.webpackChunk_repo_docs=self.webpackChunk_repo_docs||[]).push([[3359],{3441:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>p,contentTitle:()=>c,default:()=>h,frontMatter:()=>d,metadata:()=>a,toc:()=>l});var r=s(4512),n=s(3250);function o(e){const t={code:"code",p:"p",pre:"pre",strong:"strong",...(0,n.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.p,{children:"Instances of the proxy base URL are replaced by the dev server's base URL in proxied responses.\nOtherwise, absolute URLs would still point to the proxied server."}),"\n",(0,r.jsxs)(t.p,{children:["This won't work for all setups. But, ",(0,r.jsx)(t.strong,{children:"bud.proxy"})," takes a second, optional parameter to customize this default behavior."]}),"\n",(0,r.jsxs)(t.p,{children:["Each search/replace is expressed with a ",(0,r.jsx)(t.code,{children:"tuple"}),". The first item is the\nsearch string, and the second is the replacement:"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"const replacement = ['search string', 'replace string']\n"})}),"\n",(0,r.jsxs)(t.p,{children:["These are stored by ",(0,r.jsx)(t.strong,{children:"bud.js"})," as an array:"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"const replacements = [\n ['find', 'replace'],\n ['find2', 'replace2'],\n]\n"})}),"\n",(0,r.jsx)(t.p,{children:"You can add additional replacements using a callback:"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",metastring:"title='bud.config.ts'",children:"bud.proxy('https://example.test', (replacements = []) => {\n replacements.push(['https://find.test', 'https://replace.test'])\n return replacements\n})\n"})}),"\n",(0,r.jsx)(t.p,{children:"To fully ovewrite these search/replace tasks, you can pass the array without a callback:"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",metastring:"title='bud.config.ts'",children:"bud.proxy('https://example.test', [\n ['https://find.test', 'https://replace.test'],\n])\n"})})]})}function i(e={}){const{wrapper:t}={...(0,n.a)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(o,{...e})}):o(e)}const d={title:"bud.proxy: modifying the response body",description:"Modify the response body of proxied requests.",sidebar_label:"Modifying the response body",custom_edit_url:"https://github.com/roots/bud/tree/main/sources/@roots/bud-api/docs/proxy"},c=void 0,a={id:"bud.proxy/modifying-the-response-body",title:"bud.proxy: modifying the response body",description:"Modify the response body of proxied requests.",source:"@site/content/reference/bud.proxy/modifying-the-response-body.mdx",sourceDirName:"bud.proxy",slug:"/bud.proxy/modifying-the-response-body",permalink:"/reference/bud.proxy/modifying-the-response-body",draft:!1,unlisted:!1,editUrl:"https://github.com/roots/bud/tree/main/sources/@roots/bud-api/docs/proxy",tags:[],version:"current",frontMatter:{title:"bud.proxy: modifying the response body",description:"Modify the response body of proxied requests.",sidebar_label:"Modifying the response body",custom_edit_url:"https://github.com/roots/bud/tree/main/sources/@roots/bud-api/docs/proxy"},sidebar:"items",previous:{title:"bud.proxy",permalink:"/reference/bud.proxy/"},next:{title:"Options",permalink:"/reference/bud.proxy/options"}},p={},l=[];function u(e){return(0,r.jsx)(i,{})}function h(e={}){const{wrapper:t}={...(0,n.a)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(u,{...e})}):u()}},3250:(e,t,s)=>{s.d(t,{Z:()=>d,a:()=>i});var r=s(2735);const n={},o=r.createContext(n);function i(e){const t=r.useContext(o);return r.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:i(e.components),r.createElement(o.Provider,{value:t},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.