Context variables accessible to JSVM middleware?

https://www.tyk.io/docs/concepts/context-variables/

Are there any plans to expose access to these context variables in the JSVM?

2 Likes

Not yet, and they are collected after the pre-processing middleware and then throughout the middleware lifecycle, so would only really be useful in auth or post JSVM MWs

Yeah really need this for this pre “auth” hook I am trying to implement, the auth service I invoke takes this for auditing purposes…

What specific data are you looking for?

requested “Host:”, the original requesting IP address etc

I see, you can pull this data from the headers array for now?

In the request’s I’ve been logging vis JSON.stringify(request) I don’t see those headers in the object passed to the function (i.e. like remote_addr isn’t a normal header)

Right, that’s a valid point - you could look at the XFF header if you are running behind a Load Balancer?