Users accessing applications within a Virtual Desktop Infrastructure (VDI) environment report that certain application features are inaccessible.
Here users is accessing locally hosted sites http://localhost:4600 in web browser which is making request to ZTNA custom domain application(e.g., https://example.com) to fetch some token or data. Request to https://example.com is failing with CORS error. The browser's developer console shows request failed with the following error message:
"Access to fetch at 'https://example.com' from origin 'http://localhost:4600' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."
Important note: In this scenario, the frontend server is http://localhost:4600 and the backend server is https://example.com.
ZTNA Segment custom domain application access via WSS Agent or ESA agent
The issue is caused by a Cross-Origin Resource Sharing (CORS) policy violation. The browser blocks the request because the target API endpoint (e.g., https://example.com) does not explicitly permit the origin of the requesting application(e.g., http://localhost:4600). In VDI environments, this often happens when a locally hosted development or testing site attempts to fetch tokens or data from a secured API endpoint.
To resolve this issue, the backend API server or the API Gateway (e.g., https://example.com) must be configured to include the appropriate CORS headers in its response.
Steps to Implement:
Header Name: Access-Control-Allow-Origin
Header Value: http://localhost:4600
Example Configuration
If the application is running on 'http://localhost:4600' and needs to access 'https://example.com, the server(e.g., 'https://example.com') response header should look like following:
HTTP/1.1 200 OK
Content-Type: application/json
Access-Control-Allow-Origin: http://localhost:4600
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization