'access-control-allow-origin' accessing rest api of Tosca

馋奶兔 提交于 2019-12-14 03:05:30

问题


I am trying to call Tosca's rest api from my server and it's giving me this exception: 'access-control-allow-origin'. Since I have no control over Tosca's response, is there a way to get around this exception?


回答1:


Most likely the issue is not related to Tosca REST API, rather is a CORS problem. So, I am assuming your web server and the Tosca REST API server are on different domain. You can basically bypass this problem by allowing cross-origin requests from the web application, by adding the following configuration to the web.config

<system.webServer>
<httpProtocol>
  <customHeaders>
    <add name="Access-Control-Allow-Headers" value="Content-Type" />
    <add name="Access-Control-Allow-Methods" value="GET, POST" />
    <add name="Access-Control-Allow-Origin" value="*" />
  </customHeaders>
</httpProtocol>
</system.webServer>


来源:https://stackoverflow.com/questions/47333467/access-control-allow-origin-accessing-rest-api-of-tosca

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!