fastify-method-override
v1.5.10
Published
plugin for fastify override http verbs
Downloads
379
Maintainers
Readme
fastify-method-override
Plugin for Fastify, which allows use HTTP verbs, such as DELETE, PATCH, HEAD, PUT, OPTIONS in case the client doesn't support them. Supports Fastify versions >=2.0.0
.
Install
$ npm install fastify-method-override
Usage
import fastify from 'fastify';
import fastifyMethodOverride from 'fastify-method-override';
const app = fastify();
app.register(fastifyMethodOverride);
To override the HTTP method, use the HTML form with the hidden _method field and the value of the target method:
<form method="POST" action="/url">
<input type="hidden" name="_method" value="DELETE">
<input type="submit" value="Submit">
</form>
Note
If you use setNotFoundHandler, the plugin may not work correctly. In order to override the standard 404 error handler, you must use setErrorHandler.
If you are having trouble using the plugin, you can use the fastify-method-override-wrapper
library.