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?

已提问 2 年前1022 查看次数
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!

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则