Serverless-offline: process.env.IS_OFFLINE is not working

Created on 14 Apr 2020  路  4Comments  路  Source: dherault/serverless-offline

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

Most helpful comment

I see that process.env.IS_OFFLINE has been restored in 8755d9d

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FranzSkuffka picture FranzSkuffka  路  3Comments

ozbillwang picture ozbillwang  路  4Comments

aldofunes picture aldofunes  路  3Comments

Rafaelsk picture Rafaelsk  路  4Comments

dnalborczyk picture dnalborczyk  路  3Comments