Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Using Node.JS app with specific Target URL Path

I am hosting a simple node.js application within an APIProxy which will accept traffic via:

Proxy Endpoint:

/tms-sales-order/details/hello122

Hosted Target Endpoint:

/sales-order-gl/svc/v1/sales-Order/hello122

Using Trace I see the Proxy Endpoint accepts the incoming request and performs its configured Flows. The issue happens when attempting to send to the HostedTarget backend located in "/resources/hosted" directory. Attaching images of the CURL command being sent via Trace to the HostedTarget. It is also good to note, this node.js app works perfectly local and works within the proxy itself when I simply set the index.js file to accept anything, i.e. "/**" rather than attempting to set the specific URL. As you can see from the CURL request going to the HostedTarget backend only shows https://localhost with no other path context or URI pathing. Also, the Runtime Logs show the Node.js is deployed and listening and the Build Logs show the API Proxy is also deployed successfully.

Below is configuration text for the following:

CURL Request Sent to HostedTarget Node.js applicaiton:

curl -X GET -H 'Accept: */*' -H 'Accept-Encoding: gzip,deflate' -H 'Authorization: *****' -H 'Cache-Control: no-cache' -H 'Content-Type: application/json' -H 'Postman-Token: e3246dd5-bfdc-4828-bf19-a06e0640c002' -H 'X-Forwarded-For: ' -H 'X-Forwarded-Port: 443' -H 'X-Forwarded-Proto: https' 'http://localhost'

Target/default.xml

HTTPTargetConnection:

<HTTPTargetConnection> 
  <Properties/> 
  <SSLInfo> 
    <Enabled>true</Enabled> 
  </SSLInfo> 
  <LoadBalancer> 
    <Server name="mockTarget"/> 
  </LoadBalancer> 
  <Path>Some Custom Path</Path> 
</HTTPTargetConnection> 
<HostedTarget/>

resources/hosted index.js:

// Simple HelloWorld. 
app.get('SOME CUSTOM PATH', function (req, res) {
 console.log(req.query);
 res.send("Hello World!");
});

Error in the trace log says a couple of different things in the trace flow:

error.class com.apigee.errors.http.server.BadGateway
error.content { "status" : "500", "message": "Unhandled Error", "info" : "Provide URL " }
flow.edge.error.reason Internal Server Error
Body
{ 
  "status" : "500",
  "message": "Unhandled Error",
  "info" : "Provide URL "
}
		

Any thoughts on how I can get the <HostedTarget/> to send a context path and URI to the hosted node.js application instead of just https://locahhost? If I have the node.js app accept anything via "/**" it works, but this is not what I am trying to do.....All help is appreciated.

0 3 3,549
3 REPLIES 3