diff --git a/src/adapter/handler.ts b/src/adapter/handler.ts index acb4f57..0632da8 100644 --- a/src/adapter/handler.ts +++ b/src/adapter/handler.ts @@ -32,6 +32,14 @@ const app = express(); // Disable X-Powered-By header. app.disable("x-powered-by"); +/** + * Endpoint used by AWS Lambda Web Adapter for readiness checks. + * @see https://github.com/awslabs/aws-lambda-web-adapter#readiness-check + */ +app.get("/__ping", (_req, res) => { + res.status(200).send("Pong"); +}); + // Register a route which listens to all requests. app.all("*", async (req, res) => { /** diff --git a/src/cdk/GatsbySite.ts b/src/cdk/GatsbySite.ts index 3f32b9c..7ba9f2f 100644 --- a/src/cdk/GatsbySite.ts +++ b/src/cdk/GatsbySite.ts @@ -209,8 +209,9 @@ export class GatsbySite extends Construct { layers: [webAdapterLayer, ...(functionOptions.layers ?? [])], environment: { ...functionOptions.environment, - // Required by web adapter. + // Configuration for AWS Lambda Web Adapter. AWS_LAMBDA_EXEC_WRAPPER: "/opt/bootstrap", + AWS_LWA_READINESS_CHECK_PATH: "/__ping", }, });