rest - express: add handler to route with any method -


I want to add a header to any endpoint, no matter what method is used (get, post To get

, I do it like this:

  app.get ('/ *', function (rick, ridge, Next {res.setHeader ("Access-control-Alo-origin", "*"); Next (); // http://expressjs.com/guide.html#passing-route control});   

I wonder if there is a better way to do this in which the app Post, app. There is no copy for input and app. Delete

You are searching for app.all ()

Your example Then it will be created:

  app All ('/ *', function (rik, ridge, next) {res.setHeader ("access-control-permission-origin", "*"); next ();});             

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -