Access ENVIRONMENT variable from withing JSVM middleware

Evaluating running Tyk on docker, w/ some customer JSVM middleware plugins. I’d like to be able to launch the gateway containers w/ a docker env var such as "-e “MYVAR=MYVAL”… and subsequently would like to be able to access the value of MYVAR from within a middleware JS plugin


Right now not, but it should be possible to add such functionality in future.

Tyk expose several functions to the JS API, and they defined here

Function that’s gets environment, should be written the same way.


Is it now possible to use ENVIRONMENT variable from withing JSVM middleware


@marekp No, this has not been implemented.

I haven’t tried nor do I know the performance implications but you may be able to use os.Getenv() to retrieve environment variables. The gateway is open source, so you can modify it and build a custom version for your use case.

TykGetKeyData can be used as a template to write your custom JS function. Hope this helps.