Skip to content

Commit 1468af6

Browse files
authored
Merge pull request #894 from pipecat-ai/docs/pr-4704
docs: update for pipecat PR #4704
2 parents a3fb63f + ab92439 commit 1468af6

3 files changed

Lines changed: 40 additions & 11 deletions

File tree

api-reference/server/services/transport/fastapi-websocket.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,23 @@ Inherits from `TransportParams` with additional WebSocket-specific parameters.
131131
that need longer to complete a graceful close.
132132
</ParamField>
133133

134+
<ParamField path="allowed_origins" type="list[str]" default="[]">
135+
List of allowed origins for WebSocket connections. Empty list allows all
136+
origins. When set, connections with a missing or disallowed `Origin` header
137+
are rejected before the WebSocket handshake completes. Defaults to
138+
`PIPECAT_ALLOWED_ORIGINS` environment variable (comma-separated).
139+
</ParamField>
140+
134141
## Usage
135142

136143
FastAPIWebsocketTransport integrates with your FastAPI application to handle telephony WebSocket connections. It works with telephony frame serializers to process audio streams from phone calls.
137144

145+
<Note>
146+
The transport constructor raises `ValueError` if `params.allowed_origins` is
147+
set and the connection's `Origin` header is missing or not in the allowed
148+
list. The caller is responsible for closing the WebSocket in that case.
149+
</Note>
150+
138151
See the [complete example](https://github.com/pipecat-ai/pipecat-examples/tree/main/twilio-chatbot) for a full implementation including:
139152

140153
- FastAPI WebSocket endpoint configuration

api-reference/server/services/transport/websocket-server.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ Inherits from `TransportParams` with additional WebSocket-specific parameters.
120120
timeout.
121121
</ParamField>
122122

123+
<ParamField path="allowed_origins" type="list[str]" default="[]">
124+
List of allowed origins for WebSocket connections. Empty list allows all origins.
125+
When set, connections with a missing or disallowed `Origin` header are rejected
126+
before the WebSocket handshake completes. Defaults to `PIPECAT_ALLOWED_ORIGINS`
127+
environment variable (comma-separated).
128+
</ParamField>
129+
123130
### WebsocketClientTransport
124131

125132
<ParamField path="uri" type="str" required>

api-reference/server/utilities/runner/guide.mdx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -339,17 +339,20 @@ The development runner accepts several command-line arguments to customize its b
339339
python bot.py [OPTIONS]
340340

341341
Options:
342-
--host TEXT Server host address (default: localhost)
343-
--port INTEGER Server port (default: 7860)
344-
-t, --transport Restrict to a single transport and set it as the default
345-
for /start: daily, webrtc, twilio, telnyx, plivo, exotel.
346-
Omit to support all transports simultaneously (default).
347-
-x, --proxy TEXT Public proxy hostname for telephony webhooks (required for telephony)
348-
--esp32 Enable SDP munging for ESP32 WebRTC compatibility
349-
-d, --direct Connect directly to Daily room for testing (automatically sets transport to daily)
350-
--dialin Enable Daily PSTN dial-in webhook handling
351-
--whatsapp Verify required WhatsApp environment variables are present
352-
-v, --verbose Increase logging verbosity
342+
--host TEXT Server host address (default: localhost)
343+
--port INTEGER Server port (default: 7860)
344+
-t, --transport Restrict to a single transport and set it as the default
345+
for /start: daily, webrtc, twilio, telnyx, plivo, exotel.
346+
Omit to support all transports simultaneously (default).
347+
-x, --proxy TEXT Public proxy hostname for telephony webhooks (required for telephony)
348+
--allowed-origins [ORIGIN] Allowed origins for HTTP and WebSocket connections.
349+
Can be specified multiple times. Omit or leave empty to allow
350+
all origins. Defaults to PIPECAT_ALLOWED_ORIGINS env var.
351+
--esp32 Enable SDP munging for ESP32 WebRTC compatibility
352+
-d, --direct Connect directly to Daily room for testing (automatically sets transport to daily)
353+
--dialin Enable Daily PSTN dial-in webhook handling
354+
--whatsapp Verify required WhatsApp environment variables are present
355+
-v, --verbose Increase logging verbosity
353356
```
354357

355358
### Key Arguments
@@ -366,6 +369,8 @@ Options:
366369

367370
**`--dialin`**: Enables the `/daily-dialin-webhook` endpoint for handling Daily PSTN dial-in calls. This endpoint receives webhook data from Daily when a phone call dials into your configured phone number, creates a SIP-enabled room, and spawns your bot. (It no longer requires `-t daily`, though dial-in is a Daily feature.)
368371

372+
**`--allowed-origins`**: Restricts which origins can connect to HTTP and WebSocket endpoints. Useful for preventing Cross-Site WebSocket Hijacking (CSWSH) attacks. When set, connections with a missing or disallowed `Origin` header are rejected. Can be specified multiple times for multiple origins. Defaults to the `PIPECAT_ALLOWED_ORIGINS` environment variable (comma-separated). Leave unset to allow all origins.
373+
369374
**`--esp32`**: Enables SDP (Session Description Protocol) modifications needed for ESP32 WebRTC compatibility. Must be used with a specific IP address via `--host`.
370375

371376
### Environment Variables
@@ -384,6 +389,10 @@ Different transports require different environment variables:
384389
- `PLIVO_AUTH_ID`, `PLIVO_AUTH_TOKEN`: Plivo credentials
385390
- `TELNYX_API_KEY`: Telnyx API key
386391

392+
**Security**:
393+
394+
- `PIPECAT_ALLOWED_ORIGINS`: Comma-separated list of allowed origins for HTTP and WebSocket connections. When set, the runner and WebSocket transports reject any connection whose `Origin` header is missing or not in this list. Leave unset or empty to allow all origins. Example: `https://example.com,https://app.example.com`
395+
387396
The runner automatically uses these environment variables when creating transport sessions and authentication tokens.
388397

389398
## Simplifying with the Transport Utility

0 commit comments

Comments
 (0)