In previous versions of the plugin, process.env.IS_OFFLINE worked correctly, but after updating it shows undefined.
Do I need to configure something else or is it a bug?
package.json dependecies
"serverless-domain-manager": "3.3.1",
"serverless-dotenv-plugin": "^2.3.2",
"serverless-offline": "^6.1.4",
"serverless-plugin-include-dependencies": "4.0.0"
serverless --version
Framework Core: 1.67.3
Plugin: 3.6.6
SDK: 2.3.0
Components: 2.29.2
It seems to be removed feature: https://github.com/dherault/serverless-offline/issues/768
So simple work-around would e.g. like this
provider:
environment:
IS_OFFLINE: true
# or with parameter check, which is set when launching > OFFLINE=true sls offline start
# IS_OFFLINE: ${env:OFFLINE}
Thank you very much for your help and readiness.
It works. =]
The removal of IS_OFFLINE (and preserveTrailingSlash) has been a complete pain for me.
I'm not going to be one of those that demand that a pet feature is returned as I know maintainers have their own priorities and needs. But I did want to share that they had value to me.
IS_OFFLINE was useful to me because I have a common library that needs to work both as an express server and a Serverless lamba (on AWS and offline) (I use serverless-http). Because the request paths are different in each scenario, I relied on IS_OFFLINE to make the changes necessary.
Relying on the caller setting IS_OFFLINE would mean changing everywhere this library is used even if the calling code doesn't use the variable itself.
Removing preserveTrailingSlash broke my code that used serverless-http and express static(). Trailing slashes are required to serve a directory.
I have finally managed to work around losing these, so I am happy that I can upgrade to 6.x. Just a little frustrated, that's all. ;P
I see that process.env.IS_OFFLINE has been restored in 8755d9d
Most helpful comment
I see that
process.env.IS_OFFLINEhas been restored in 8755d9d