javascript - 将 Azure MobileServiceClient 与本地后端连接

标签 javascript azure asp.net-web-api

我想调试 WebApi 客户端项目。

客户端示例来自 Azure,可供使用。我通过更改显示的行将其配置为使用本地 WebAPI 后端

var client = new WindowsAzure.MobileServiceClient('https://myproject-code.azurewebsites.net', 'https://someGateWay.azurewebsites.net', '');

var client = new WindowsAzure.MobileServiceClient('http://localhost:59477/', '', '');

如您所见,API 在端口 59477 上运行。当我刷新客户端(端口 4400)时,它查询 API 并遇到 CORS 异常:

No 'Access-Control-Allow-Origin' header is present on the requested resource

如何设置它以在本地开发和调试服务器和客户端?

最佳答案

我还没有尝试过这个,因为我通常在我的移动应用程序中使用 JavaScript 后端,但您只需要告诉移动应用程序允许 localhost 通过 CORS 访问它。这篇文章关于Azure Mobile Services .NET Adds CORS Support, Better Authentication应该可以带你到达那里。

关于javascript - 将 Azure MobileServiceClient 与本地后端连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31639527/

相关文章:

javascript - Collection.get 在 backbone.js 中返回未定义

Azure devops Octopus部署版本名称semver检查

angularjs - $http.post 的 Web API 405 错误

asp.net - 如何部署具有多个项目的单个解决方案?

Javascript:location.hostname 和 document.domain 之间的区别?

javascript - 如何隐藏多个表单并通过事件单击jquery显示其中一个表单

javascript - JSON Stringify 和 AJAX 解析错误

azure - Azure 上的 .NET Core 2.0 导致 502.3 CGI 错误

azure - 自动刷新 token 并添加新的用户安全组 Azure AD

c# - 初学者在这里 : How does my Repository Layer know which user is logged in?