Deploy a node.js file and create multiple proxies for it based on the path

Not applicable

Suppose I have a simple node.js file as follows:

var express=require('express')

var app=express()

app.get('/login',function(req,res){ res.send('Welcome to login!') })

app.post('/login',function(req,res){

res.send('Successful!')

})

app.get('/register',function(req,res){

res.send('')

})

app.listen(8081)

Now when I deploy this on Apigee, I want to create multiple proxies for this file based on the path. Like I want to create a separate proxy for /login and /register.

Can someone help me figure this out?

0 2 461
2 REPLIES 2

HI @Karthik Kamath

I dont think its meant for that. If you have a NodeJS code built for those resources, its the same in apigee as well. The whole purpose of using Apigee and NodeJS is to keep all that together and use Apigee as a gateway to your APIs written in NodeJS. I would use the same NodeJS app and deploy that in Apigee. Use them as different resources and define a basepath in Apigee - something like /v1/auth so that once its deployed in Apigee, you can call https://{host}/v1/auth/login and https://{host}/v1/auth/register

Not applicable

Hello @Karthik Kamath ,

Thee are 2 ways to achieve this:

1. Proxy Chaining: Expose an API proxy with node.js source as the target and create multiple proxies with that former node.js proxy as the target.

2. You can have one single API bundle with multiple proxy configurations. So, under proxies directory, you can have multiple proxy configurations eg: login.xml, register.xml, and all the proxy configurations can point to the same node.js target depending upon your requirement.