Luiz Eduardo de Christo Luiz Eduardo de Christo - 23 days ago 12
Node.js Question

Express method-override in node.js

In a node application at server.js file, what is the difference between use:

app.use(methodOverride());


or use:

app.use(methodOverride('X-HTTP-Method-Override'));


Both of them works. I just want to know if there is any difference between.

Thanks in advance.

Answer

From the docs: https://github.com/expressjs/method-override

Essentially, it will retrieve your method override from the X-HTTP-Method-Override header by default. Specifying it makes no difference.

If you were to retrieve your method override from an alternative header, X-Foo-Bar, you would use app.use(methodOverride('X-Foo-Bar'));.

If you were to retrieve your method override from a query string, foo=PUT, you would omit the X- prefix, e.g. app.use(methodOverride('foo'));