From 7c333430bd9c4d9873433b1d051adbdbee290355 Mon Sep 17 00:00:00 2001 From: Sparticuz Date: Fri, 5 May 2023 14:34:10 -0400 Subject: [PATCH] add netlify env check --- source/helper.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/helper.ts b/source/helper.ts index 1e9d2e1..97cc36d 100644 --- a/source/helper.ts +++ b/source/helper.ts @@ -19,7 +19,9 @@ export const isValidUrl = (input: string) => { /** * Determines if the running instance is inside an AWS Lambda container. - * @returns + * AWS_EXECUTION_ENV is for native Lambda instances + * AWS_LAMBDA_JS_RUNTIME is for netlify instances + * @returns boolean indicating if the running instance is inside a Lambda container */ export const isRunningInAwsLambda = () => { if ( @@ -27,6 +29,11 @@ export const isRunningInAwsLambda = () => { /^AWS_Lambda_nodejs/.test(process.env["AWS_EXECUTION_ENV"]) === true ) { return true; + } else if ( + process.env["AWS_LAMBDA_JS_RUNTIME"] && + /^nodejs/.test(process.env["AWS_LAMBDA_JS_RUNTIME"]) === true + ) { + return true; } return false; };