多亏了CORS,我无法连接到我的桌子?

时间:2019-04-18 14:42:52

标签: azure azure-cosmosdb azure-table-storage

我正在尝试使用Vue连接到Table的API;但是,我总是收到以下错误。

我尝试更改CORS设置,但是不存在。我只想使用axios进行API调用。

getUser () {
      //const URL = 'https://holy-knight.table.core.windows.net/Users(PartitionKey=Persons,RowKey=000)?$select=PartitionKey'
      const URL = 'https://holy-knight-table.table.cosmos.azure.com:443/Tables'
      axios
      .get(URL, {crossdomain: true}).then((res) => {
        // this.user = res.data
        console.log(res.value)
      })
    },
GET https://holy-knight-table.table.cosmos.azure.com/Tables 404

Access to XMLHttpRequest at 'https://holy-knight-table.table.cosmos.azure.com/Tables' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

createError.js?2d83:16 Uncaught (in promise) Error: Network Error
    at createError (createError.js?2d83:16)
    at XMLHttpRequest.handleError (xhr.js?b50d:87)

1 个答案:

答案 0 :(得分:0)

CORS当前仅可用于 Core(SQL)Cosmos 帐户,请参阅:https://docs.microsoft.com/azure/cosmos-db/how-to-configure-cross-origin-resource-sharing

在您的情况下,您似乎正在使用Table API帐户,但该API类型似乎尚未提供CORS。