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개 답변
1
수락된 답변

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
전문가
Uri
답변함 2년 전
  • Many thanks for pointing me in the right direction!

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인