Configure CORS to allow specific origins you define or well-known origins 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.
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 to 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.
The header value populates with the origin the filter approves.