How to access context variable like app_name, Clientid and others in hosted Nodejs App

I have hosted one Nodejs app on APIGEE edge and some of the parameters like app_name, scopes and others I need to send it to backend services. How can I access those variable in hosted nodejs App.

I have tried doing context.getVariable but didnt work well. Can someone please help?

Solved Solved
0 3 545
1 ACCEPTED SOLUTION

I think the nodejs targets were deprecated some time ago. A couple years?  Maybe 2018? 

So you should not be using them. 

Can you clarify what you're using?  

Maybe it's a "hosted target" which is also deprecated at this point. (Sorry) 

The way I've solved this problem is, in the target flow, use AssignMessage to explicitly add query params or headers to the request that gets sent to the hosted target.  Then extract that information using the normal nodejs mechanisms from that hosted target.  

View solution in original post

3 REPLIES 3

Is it possible to work around the lack of apigee-access?

You cannot use the apigee-access module in Hosted Targets apps. If you use traditional, embedded Node.js with apigee-access and want to migrate to Hosted Targets, consider the following possibilities:

  • Use Edge policies - Where possible, use standard Edge policies to replace what your existing apigee-access code does.
  • Use headers - You can put KVM values and flow variables to your Node.js application in HTTP request headers. This strategy works for KVM values or flow variables that are available in the request flow of the API proxy.

I think the nodejs targets were deprecated some time ago. A couple years?  Maybe 2018? 

So you should not be using them. 

Can you clarify what you're using?  

Maybe it's a "hosted target" which is also deprecated at this point. (Sorry) 

The way I've solved this problem is, in the target flow, use AssignMessage to explicitly add query params or headers to the request that gets sent to the hosted target.  Then extract that information using the normal nodejs mechanisms from that hosted target.  

Yes I did the same thing have created a Assign message policy and got everything I needed as Query Parameter in Nodejs Request.

Thankyou so much