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.

important
Ensure that the Lambda proxy integration toggle is turned on.
#
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:
- Select the 'Default 4XX' and 'Default 5XX' checkboxes under Gateway responses
- Select the 'OPTIONS' checkbox under Methods
- Add
rid,fdi-version,anti-csrf,st-auth-mode
to the existingAccess-Control-Allow-Headers
- Set
Access-Control-Allow-Origin
to'<YOUR_WEBSITE_DOMAIN>'
- Select
Access-Control-Allow-Credentials
checkbox

#
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
.
important
Update apiDomain
, apiBasePath
, and apiGatewayPath
in both Lambda configuration and your frontend config if they have changed post API Gateway configuration.