Error 363650, No Access-Control-Allow-Origin, Cross-Origin Resource Sharing Error

Updated Mar 21, 2019

Reported In

Software

  • LabVIEW NXG Web Module

Issue Details

  • I am receiving the following error when trying to run my LabVIEW NXG WebVI:
JavaScript message in Main.html at line 0: XMLHttpRequest cannot load http://127.0.0.1:8001/Web_Server/ParametricCurve. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:51485' is therefore not allowed access.
  • When trying to connect to a LabVIEW Web Server from a LabVIEW NXG WebVI I get Error 363650 stating that a Network error has occurred, and that a possible reason is cross origin resource sharing, or that the client cannot reach the target server

Solution

In your LabVIEW Web Server, use the Set HTTP Header.vi to set the HTTP Header field "Access-Control-Allow-Origin". You could specify the allowed domain on its own, or choose the value "*" to allow any domain. Note that using the asterisk, “*”, to allow any domain has security implications that should be researched and reviewed before this solution is implemented.

Note: The LabVIEW Web Server is hosted in LabVIEW 2018 or compatible while the Web VI is built in LabVIEW NXG. 

Additional Information

You can learn more about using Cross-Origin Resource Sharing outside of the LabVIEW context by looking at the Using CORS tutorial published by Html5 Rocks or by looking at Cross-Origin Resource Sharing (CORS) whitepaper by Mozilla

WAS THIS ARTICLE HELPFUL?

Not Helpful