Access to fetch at 'http://localhost:3000/fetch/fetchGet/456' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

express跨域_解决方法

解决方法:

服务端添加允许跨域(以下为node.js express框架)

// 允许跨域
app.all('*', function(req, res, next) {
res.setHeader(
'Access-Control-Allow-Origin', '*'
)
next();
})