与 http-proxy-middleware 反应 - 自定义标头

问题描述

我在 React 应用中定义了以下代理:

    app.use(
      '/api',createProxyMiddleware({
         target: 'http://api.my-app.com',changeOrigin: true,onError: (err,req,res) => {
            res.writeHead(500,{
               'Content-Type': 'text/plain',})
            res.end(
               'Something went wrong. And we are reporting a custom error message.' +
               err
            )
         },})
   );

是否可以使用此代理配置为每个传出请求添加标头?如果是这样,如何?提前致谢:)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)