Are you running the latest gateway container with 2.3.8?
This works for me:
Code:
var helloWorld = new TykJS.TykMiddleware.NewMiddleware({});
log("------------ Initialising PRE middleware ------------");
helloWorld.NewProcessRequest(function(request, session, config) {
// You can log to Tyk console output by calloing the built-in log() function:
log("Running sample PRE PROCESSOR JSVM middleware with iteration")
for (var i in config.config_data) {
log(i)
log(config.config_data[i])
}
// You MUST return both the request and session metadata
return helloWorld.ReturnData(request, {});
});
// Ensure init with a post-declaration log message
log("------------ Sample PRE middleware initialised ------------");
Output:
[Aug 17 21:32:11] INFO jsvm-logmsg: a type=log-msg
[Aug 17 21:32:11] INFO jsvm-logmsg: b type=log-msg
[Aug 17 21:32:11] INFO jsvm-logmsg: x type=log-msg
[Aug 17 21:32:11] INFO jsvm-logmsg: y type=log-msg```
The gateway is configured w/ coprocess on, and a bundle url. The API def references a bundle zip file, that is successfully being pulled and installed locally on the gateway, and invoked… just that config_data seems undefined.
I’ve tried deleting the config_data in the admin.cloud.tyk.io dashboard, and re-creating it, to no avail. The API when invoked on the gateway is definitely invoking the function, but that config variable is undefined.
FYI @Martin, doing a custom image against the hybrid 2.3.8 image, still shows this issue, only “latest” has the fix. Something may be messed up w/ your image signatures on dockerhub fyi