我使用node.fetch和react.js。正如文档中提到的,我可以用这种方式缓存图像缓冲区。节点提取网址,如何去掉主机名端口
var fileType = require('file-type');
fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png')
.then(function(res) {
return res.buffer();
}).then(function(buffer) {
fileType(buffer);
});
但是因为我的react.js在localhost:3000上运行,取回请求会自动在URL中追加:3000。在这种情况下,https://assets-cdn.github.com:3000 /images/modules/logos_page/Octocat.png。
但是这个URL无效,我该如何删除端口?
如果您传递完全限定的URL,'fetch()'不会添加端口。 – jfriend00