- Newest
- Most votes
- Most comments
Hello,
Warm Greetings of the day!
I understand that you wish to attach the Lambda authorizer for all routes like $connect route in WebSocket API Gateway. Please note that the WebSocket connection is a stateful connection. Hence, authorization will be performed at connection time and this setting is applied to the entire API and not just the $connect route. The $connect route protects the other routes, because it is called on every connection.
The routes like $default/custom routes are invoked after the WebSocket connection is already established. At this point, the client has already connected successfully, so authorization is not required from a security perspective.
However, if you are looking for authorization in Websocket API for all the other routes, you need to implement this in the backend. Here, the backend needs to perform the validation and decide if it wants to authenticate the connection or not.
Hope this answers your query. Thank you!
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 5 months ago

Hello, Thank you so much for your time and answer. I will try to implement in the backend as you have suggested.