You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I expect , I want implement a proxy on the vite to forwarding my local mock data when the backend api not implement(404), This is useful because the backend api is not always in sync with the frontend.
There is my code , but cannot get the response, thanks for everyone's help.
proxy:{
'/api':{
target:'http://www.example.com',
selfHandleResponse:true,
configure:proxy=>{
proxy.on('proxyRes',(proxyRes,req,res)=>{
if(proxyRes.statusCode===404){
// how to do here?
proxy.web(req,res,{target:'http://www.newExample.com'})
}else{
proxyRes.pipe(res)
}
})
}
}
}
The text was updated successfully, but these errors were encountered:
Hi everyone.
I am using vite+vue in my project.
As I expect , I want implement a proxy on the vite to forwarding my local mock data when the backend api not implement(404), This is useful because the backend api is not always in sync with the frontend.
There is my code , but cannot get the response, thanks for everyone's help.
The text was updated successfully, but these errors were encountered: