node.js - Use csrf only for defined routes in restify -


i have restify application (simple api). use csurf library preventing csrf requests.

but need don't use csrf validation on several routes.

first idea, think - create array routes don't need use csrf , validate current route.

var routesnocsrf = ['/api/route1', '/api/route2']; if (routesnocsrf.indexof(currentroute) === -1) {   server.use(csrf({     cookie: true,     ignoremethods: ['head', 'options']   })); } 

but on step didn't have access currentroute

second - divide 1 api 2 different apis - , first use csrf validation second - not. in case - create 2 different servers, listen 2 different ports.

but using 1 app. possible ?

there complete example ignoring routes on csurf github page.

https://github.com/expressjs/csurf


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -