How to retrieve path parameters from websocket url in lambda functions

0

When we deploy the websocket in API Gateway, it gives us a url like: wss://<example>.amazonaws.com/production Based on our use case, we need to pass a parameter in the url, like: wss://<example>.amazonaws.com/production/id Now when we try to connect to the first url, is works fine. But if we connect to the second url, we get a 403 error:

Error: Unexpected server response: 403 Handshake Details Request URL: https://<example>.amazonaws.com/production/id Request Method: GET Status Code: 403 Forbidden

There seems no way in AWS API Gateway to configure access to the second url.

Can anyone offer a solution for this?

1 Answer
1
Accepted Answer

This is correct. You can't append anything after the stage name. If you do you get an error.

To work around this you can deploy a CloudFront distribution in front of API Gateway and then use a CloudFront Function to modify the URL by removing the ID and placing it in a header or in a request parameter.

profile pictureAWS
EXPERT
Uri
answered 2 years ago
  • Many thanks for pointing me in the right direction!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions