-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doesn't work with custom fastify-multipart #14
Comments
+1 same problem. If I try to add code like this fastify.register(multipart);
await AdminJSFastify.buildRouter(
admin,
fastify,
) I will have error: but after disabling |
One of possible hack-solution if you really need adminjs is disabling your own multipart and using multipart in adminjs. Because in this line of adminjs-fastify/src/buildRouter.ts Line 38 in 04d9416
What you need to know:
fastify.register(require('@fastify/multipart'), {
limits: {
fieldNameSize: 100, // Max field name size in bytes
fieldSize: 100, // Max field value size in bytes
fields: 10, // Max number of non-file fields
fileSize: 1000000, // For multipart forms, the max file size in bytes
files: 1, // Max number of file fields
headerPairs: 2000, // Max number of header key=>value pairs
parts: 1000 // For multipart forms, the max number of parts (fields + files)
}
}); For fixing the bug need something as issue-starter says |
If anyone else is running into this problem, you can work around it by registering adminjs as part of a different fastify scope: const fastifyApp = fastify({})
fastifyApp.register(async (server) => {
// Register routes here with their own multipart handlers
})
fastifyApp.register(async (server) => {
const admin = new AdminJS({
databases: [],
rootPath: '/admin'
})
// Using the server instance received in the callback is important!
await AdminJSFastify.buildRouter(admin, server)
})
// Start fastify app |
buildRouter
already setup it's own fastify-multipart, so i can't do it again on my own, because it throws an error:FastifyError [Error]: The decorator 'multipartErrors' has already been added!
that's alright, but in that way i can' pass my custom params. my solution is to add a param
disableMultipart
or something like thatThe text was updated successfully, but these errors were encountered: