are there special steps that need to occur when deploying a NodeJS application so that I can make use of getVariable(...) to access values I've set in AssignMessage policies during the preflow?
calling apigee-access.getMode() always returns "standalone" and my variables are unaccessible.
Hey @Zameer Andani
I am not aware of any 'special steps' required to use apigee-access on Edge.
For your reference, here is a minimalist nodeJS targetEndpoint using Express. (You could also use http). To reduce possible variables, it was created via Edge UI and not deployed via A-127 or apigeetool.
var express = require('express'); var app = express(); var apigee = require('apigee-access'); app.listen(9000, function() { console.log('nodejs listening on Edge. Mode is '+apigee.getMode()); });
When the proxy is deployed, the nodeJS logs under Trace show the mode as 'apigee'.
Time | Level | Server | Message |
---|---|---|---|
Aug 8, 2017 11:38:25 AM | stdout | svr.950 | nodejs listening on Edge. Mode is apigee |
If you run this same code locally and then deploy to Edge, can you emulate this result ?
If you have still have problems, then consider possible version issues with modules installed via NPM on your local system, that are not working well when deployed to Edge.
thanks @Robin Martin
turned out my issue was due to using Webpack to compile the server.js I was deploying into Apigee -- I needed to make sure that webpack was not packing "apigee-access" and instead relied on Apigee Edge to provide this library.
Once I marked "apigee-access" as external in my config, all functioned correctly.
Hi Zameer,
I am facing the same issue. I am always getting mode as standalone on APIGEE Edge.
Can you please let me know how to mark "apigee-access" as external in config.
Regards
Ravi
you need to treat the Apigee module as an external when using webpack (https://webpack.js.org/configuration/externals/). This will ensure that it's not pulled into your bundle.js and instead will rely on the module deployed within Apigee itself.
hope the link helps.