create

阅读: 评论:0

create

create

在CRA2.X升级以后对proxy的设置做了修改,引用官方升级文档:

Object proxy configuration is superseded by src/setupProxy.js

To check if action is required, look for the proxy key in package.json and follow this table:

  1. I couldn't find a proxy key in package.json
    • No action is required!
  2. The value of proxy is a string (e.g. localhost:5000)
    • No action is required!
  3. The value of proxy is an object
    • Follow the migration instructions below.

It's worth highlighting: if your proxy field is a string, e.g. localhost:5000, or you don't have it, skip this section. This feature is still supported and has the same behavior.

If your proxy is an object, that means you are using the advanced proxy configuration. It has become fully customizable so we removed the limited support for the object-style configuration. Here's how to recreate it.

如果proxy的值是字符串,不需要修改

如果proxy的值是一个json,则需要做如下修改:

1. npm install http-proxy-middleware

2. src文件夹根目录下创建 setupProxy.js 文件

3. package.json中的

"proxy": {"/api": {"target": "localhost:5000/"},"/*.svg": {"target": "localhost:5000/"}
}

迁移到setupProxy.js中

const proxy = require('http-proxy-middleware');ports = function(app) {app.use(proxy('/api', { target: 'localhost:5000/' }));app.use(proxy('/*.svg', { target: 'localhost:5000/' }));
};

转载于:.html

本文发布于:2024-02-04 19:42:22,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170715023358935.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:create
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23