If both HTTP and WebSocket services are running on the same proxy, a condition must be added to the relevant policies to ensure that Apinizer policies apply only to HTTP requests. This condition ensures that WebSocket connections continue to function without being affected by policy control.
In the example scenario, the script policy added to the API proxy adds a specific Authorization header to HTTP requests. However, the intention is to exclude this script policy from being applied to WebSocket requests.
Add script policy:

On the script policy screen, switch to the Conditions tab and add a new rule.
If a variable exists, select header:Upgrade; otherwise, add a new variable with the Upgrade header type.

The condition for the Upgrade header is edited and saved as follows to include requests whose value is websocket:

This way, requests with the Upgrade header set to websocket are filtered with a condition, the script policy is applied only to HTTP requests, and the policy is disabled for WebSocket connections. This way, WebSocket traffic continues to operate without any impact.