I’m not sure you need what you’re asking for. I don’t have the same file structure as your app does, maybe you could share it. But I tried something simple, and it works just fine without knowing , a priori, the proxy basepath. I’m using express 4.12 and apigee-access 1.3.0. My package.json looks like this:
{
"name": "node-demo1",
"description": "demonstration of retrieving flow variable within a request",
"version": "0.0.2",
"main": "express-server.js",
"author" : { "name" : "Dino Chiesa"},
"scripts": {
"start": "node express-server.js",
"test": "echo \"Whoops: there are no tests\" && exit 1"
},
"license": "MIT",
"dependencies": {
"apigee-access" : "1.3.0",
"express": "4.12.3",
"body-parser" : "1.12.3"
},
"engines": {
"node": "0.10.x",
"npm": "2.8.x"
}
}
And this app code:
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var apigee = require('apigee-access');
var env = process.env;
app.use(bodyParser.json());
app.use("/about", function(req, res, next) {
var message = { "route" : 1 };
message['path-in-apigee'] = apigee.getVariable(req, 'request.path') || "unknown";
message['express-baseUrl'] = req.baseUrl;
res.json(message);
});
// catch 404
app.use(function(req, res, next) {
var payload = { message: "Not found" };
res.status(404);
res.json(payload);
});
app.listen(process.env.PORT | 8124, function() {
var host = server.address().address;
var port = server.address().port;
console.log('listening at http://%s:%s', host, port);
});
Note the “app.use” references a path “/about”.
When I send in a request like this:
curl -i [http://ORGNAME-ENVNAME.apigee.net/node-pathsuffix/about](http://ORGNAME-ENVNAME.apigee.net/node-pathsuffix/about)
I get this json response:
{
"express-baseUrl": "/about",
"path-in-apigee": "/node-pathsuffix/about",
"route": 1
}