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 Antwort
1
Akzeptierte Antwort

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
EXPERTE
Uri
beantwortet vor 2 Jahren
  • Many thanks for pointing me in the right direction!

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen