add netlify env check

This commit is contained in:
Sparticuz 2023-05-05 14:34:10 -04:00
parent b1810b4165
commit 7c333430bd
1 changed files with 8 additions and 1 deletions

View File

@ -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;
};