因此,我将一个项目(使用的框架是ReactJS)部署到Heroku,并且给定的URL使用HTTPS协议。我遇到的问题是数据的来源使用HTTP协议,因此这个错误被返回.

下面是负责获取数据的代码
import axios from 'axios';
const api = axios.create({
baseURL: 'http://api.decoprim.md/v1/items?key=3VG8BizGax',
});
export function getProducts() {
return api.get().then(response => response.data.data);
}发布于 2018-03-07 11:06:23
跨源资源共享阻塞了您的请求,如果页面加载在https之上,则应该对所有资源使用https,但如果无法更改,则可以使用第三方服务绕过它,例如:
示例基url:
https://allorigins.me/get?url=http%3A//api.decoprim.md/v1/items%3Fkey%3D3VG8BizGax&method=rawhttps://stackoverflow.com/questions/49149814
复制相似问题