Sunday, 2 April 2017

Nodejs - Set up different api version

I have following setup for api version1 which will validate token through middle ware

var app = express();
// Auth Middleware - This will check if the token is valid
// Only the requests that start with /api/version1/* will be checked for the token.
// Any URL's that do not follow the below pattern should be avoided unless you 
// are sure that authentication is not needed
app.all('/api/version1/*', [require('./middleWare/validateMyRequest')]);
app.use('/', require('./myModal'));
app.all('/*', function(req, res) {
    res.sendFile('/public/index.html', { root: __dirname });
});

Here i want to set another api version2 in server configuation in which i dont need to validate token using middle ware.I have tried with following config

app.use('/api/version2/*', require('./myModal'));

When i tried with baseurl with api version2. It always validate token and redirect to login page. Please advise what i am missing here to set up api version2?



via mymotherland

No comments:

Post a Comment