Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
399 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...