Redirect Can';t resolve Dropbox.com使用Axios或D3 fetch重定向

Redirect Can';t resolve Dropbox.com使用Axios或D3 fetch重定向,redirect,https,axios,fetch,dropbox,Redirect,Https,Axios,Fetch,Dropbox,我正在尝试从Dropbox链接获取浏览器中的数据: 使用Axios在节点中工作: axios.get('https://www.dropbox.com/s/101qhfi454zba9n/test.txt?dl=1').then(x => { console.log('Received correctly') console.log(x.data); }).catch(error => { console.log('Error', error.message);

我正在尝试从Dropbox链接获取浏览器中的数据:

使用Axios在节点中工作:

axios.get('https://www.dropbox.com/s/101qhfi454zba9n/test.txt?dl=1').then(x => {
  console.log('Received correctly')
  console.log(x.data);
}).catch(error => {
    console.log('Error', error.message);
    if (error.response) {
      // The request was made and the server responded with a status code
      // that falls out of the range of 2xx
      console.log(error.response.data);
      console.log(error.response.status);
      console.log(error.response.headers);
    } else if (error.request) {
      // The request was made but no response was received
      // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
      // http.ClientRequest in node.js
      console.log(error.request);      
    }
    console.log(error) 
});

但是,它在浏览器中不起作用(单击“控制台”选项卡):

我只是得到一个通用的“网络错误”。我看到正在检索301重定向,这似乎非常正常,但由于某些原因,它没有被遵循

D3的情况也完全相同:“尝试获取资源时出现NetworkError。”


发生了什么?

由于CORS政策,这似乎失败了。使用
XMLHttpRequest
尝试此操作直接失败:

CORS策略已阻止从源代码“…”访问“”处的XMLHttpRequest:请求的资源上不存在“访问控制允许源代码”标头


www.dropbox.com本身不允许使用CORS。

Huh,因此无法直接从浏览器访问dropbox托管的文件?dropbox提供上传和下载文件等操作,但这需要更多的工作来实现。从技术上讲,它看起来像是使用旧的dl.dropboxusercontent.com主机名(例如:
)https://dl.dropboxusercontent.com/s/101qhfi454zba9n/test.txt“
)仍然有效,但这并没有得到官方支持,可能会在不另行通知的情况下进行更改。