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 Risposta
1
Risposta accettata

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
ESPERTO
Uri
con risposta 2 anni fa
  • Many thanks for pointing me in the right direction!

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande