i’m running my serverless with serverless offline library, i’m running using sls offline
and i have several. how i detect is my lambda API triggered from localhost or server? thank you
i already try like process.env.IS_LOCAL, process.env.AWS_EXECUTION_ENV but returning undefined.
2
Answers
You can use
LAMBDA_TASK_ROOT
as inYou may want to add something like
console.log(process.env)
in your lambda handler to learn what environment variables exist in both cases called either from localhost or server, then see what you would use to detect how lambda is triggered.for example:
Would return:
Hope that helps!