Reputation: 584
I searched and couldn't find the right answer. I seem helpless. But luckily the visua code helped debug the code and I found this line in the index.js@hapi/subtext/lib file
if (contentType.mime === 'multipart/form-data') {
if (options.multipart === false) {// Defaults to true
throw Boom.unsupportedMediaType ();
}
return await internals.multipart (req, options, source, contentType);
}
I then fixed multipart = true in router opitions:
{
payload: {
maxBytes: 1024 * 1024 * 100,
// timeout: false, // important
parse: true,
output: 'data',
allow: 'multipart / form-data',
multipart: true
}
}
and it worked. Thanks for the visua code debug. I wrote back to someone who might get this error. Know how to handle.
i using hapi version 19.0.3
Upvotes: 2
Views: 1132
Reputation: 141
Form hapi 19 release notes :
Change route options.payload.multipart to false by default Route configuration default was change to disable multipart processing. You will need to either enable it for the entire server to keep previous behavior or just for the routes where multipart processing is required.
server.route({
method: 'POST',
path: '/submit',
options : {
auth : false,
payload: {
output: 'stream',
parse: true,
allow: 'multipart/form-data',
multipart : true // <== this is important in hapi 19
},
handler: async (req, h) => {
console.log(req);
}
}
});
Upvotes: 1