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
devServer: {before: (app)=>{// for some special url or *(filter `query` or other things except `url`)app.get('/api',(req,res,next)=>{// do something with `req` `res` `next`res.json({msg: 'hi~'});// next();});}}// 如果使用 vue 官方模板的话,在 proxyTable 里面
axios 拦截
instance.interceptors.request.use(function(config){// proxy triggered// you can modify the `config.url` to your target proxy serverconfig.method='post';returnconfig;},function(error){// Do something with request errorreturnPromise.reject(error);});
webpack devServer
注意: 假设 devServer 运行在
localhost:3001
下,webServer 只能代理localhost:3001/xxx
这种请求,无法拦截外部 API,比如http://external.com/xxx
,但是它可以把内部请求代理到外部。axios 拦截
参考
The text was updated successfully, but these errors were encountered: