Set up API Gateway
#
1) Create a REST API GatewayWe will be using AWS API Gateway to create a REST API that will be used to communicate with our Lambda functions.

#
2) Set up auth routesCreate a /auth
resource and then /auth/{proxy+}
resources. This will act as a catch-all for all supertokens auth routes. Enable CORS while creating the proxy resource.


ANY
method of the proxy resource#
3) Attach lambda to the Click on the "ANY" method and then "Integration" to configure the lambda function. Check Lambda proxy integration and then select your lambda function.

#
4) Enable CORS for the proxy pathClick on the {proxy+}
resource and then "Enable CORS" button to open the CORS configuration page.

- In the CORS configuration page do the following:
- Add
rid,fdi-version,anti-csrf,st-auth-mode
to the existingAccess-Control-Allow-Headers
- Set
Access-Control-Allow-Origin
to'^{form_websiteDomain}'
- Set
Access-Control-Allow-Credentials
to'true'
. Don't miss out on those quotes else it won't get configured correctly.
- Add

#
4) Deploy the API GatewayClick the Deploy API button in the top right corner to deploy the API. During deployment, you'll be prompted to create a stage; for this tutorial, name the stage dev
. After deployment, you will receive your Invoke URL
.
note
Update apiBasePath
and apiGatewayPath
in the Lambda configuration if they have changed post API Gateway configuration.