Configure CORS to allow specific origins you define, well-known origins, and origins with credentials access to your WebVI resources.
Create the following diagram in a Web Resources VI to configure a LabVIEW Web Service to allow CORS with specific or well-known origins and origins with credentials.
Customize the gray sections for your unique programming goals.
![]() |
A new Web Resources VI automatically adds the LabVIEW Web Service Request class to the block diagram and terminal pane. |
![]() |
Read Request Variable checks the request for the variable you define. To check the origin of the request, enter Origin for the value of variable. Use a Case Structure to create two cases: a case to continue if an origin is found in the request and a case to do nothing if an origin is not found in the request. |
![]() |
Define how to filter the origins you want to access your web resources. Some
common implementations include the following:
Use a Case Structure to create two cases: a case continue if the origin passes the filter you implement and a case to do nothing if the origin does not pass the filter. |
![]() |
Set HTTP Header sets the HTTP header value in response to a request. Use the header Access-Control-Allow-Origin to indicate if the origin making the request can access the response of your Web Service VI. |
![]() |
Set HTTP Header sets the HTTP header value in response to a request. Use the header Access-Control-Allow-Credentials to indicate if the origin making the request can access the response of your Web Service VI and accept credentialed information, such as cookies. Use the header value true to allow the filtered origin to access your Web Service VI. You must make a corresponding change in the Configure CORS node in your WebVI. See Sending a Credentialed Cross-Origin HTTP Request for more information. |
![]() |
Add code that only functions if the origin has supported credentials defined in the request. The code above uses session VIs that require browser cookies to function. |