Skip to main content
If both HTTP and WebSocket services are running on the same proxy, a condition must be added to the relevant policies so that Apinizer policies can only be applied to HTTP requests. Thanks to this condition, WebSocket connections continue to work without being affected by policy checks. In the example scenario, the script policy added to the API proxy adds a specific Authorization header to HTTP requests. However, it is intended that this script policy should not be applied in WebSocket requests. Script policy is added: Generate JWK Screen On the Script policy screen, switch to the Conditions tab and add a new rule. Select header:Upgrade as variable if it exists; otherwise, add the Upgrade header as a new variable of type header. Generate JWK Screen The condition for the Upgrade header is arranged and saved as follows to cover requests with the value websocket: Generate JWK Screen Thus, requests with Upgrade header as websocket are filtered by condition, the script policy is only applied to HTTP requests, and the policy is disabled in WebSocket connections. This way, WebSocket traffic continues to work without being affected.