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?
Asked
Active
Viewed 215 times
1 Answers
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>

Atanu Roy
- 1,384
- 2
- 17
- 29
-
thanks Atanu. However, I have no control over the web app. But thanks for the info. I will see if i can ask the owner of the web app to update the web.config. – arn-arn Nov 20 '17 at 16:47
-
@arn-arn Just as an update : if your app is hosted in MS Azure cloud, you can do the CORS configuration directly from Azure management portal. – Atanu Roy Nov 21 '17 at 13:04
-
thanks again Atanu. Unfortunately, that's not our setup. However, i was able to go around it by using java backend which does not throw the pre-flight error. Then my front end just calls my java backend which I can configure myself. – arn-arn Nov 22 '17 at 17:37