-
Notifications
You must be signed in to change notification settings - Fork 970
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
[Bug?]: Uploading files through custom functions doesn't work #10461
Comments
@c-ciobanu Thanks for taking the time to file this issue. I'm going to tag in another core team member to see if they can help resolve this. |
Hey @c-ciobanu sorry for taking so long for someone to get back to you. We did indeed have a bug where you weren't able to customise the api server file as the docs suggested you could. We have fixed this although it's not yet out in a published release. It should be out this week. The updated documentation is already available via the canary docs: https://redwoodjs.com/docs/canary/docker#configuring-the-server I think this would resolve your issue. It would be great to cycle back to this one once the new version is released to confirm it does indeed fix it. |
What's not working?
Uploading files using a custom function and fastify doesn't seem to work.
There was some discussion on the forum https://community.redwoodjs.com/t/uploading-files-using-redwood-function-and-fastify/5814/8 but there was no solution there so I'm opening an issue for it.
The Problem:
I am trying to create a custom function to upload files but it's not working.
I'm calling my custom function like this:
and getting the following response:
There seems to be a discrepancy on how the request body size is calculated on the server and the Content-Length header that is automatically calculated by the browser.
What I tried doing to make it work:
By looking around I discovered that if I comment out this code in the
api-server
packageredwood/packages/api-server/src/plugins/api.ts
Lines 41 to 45 in 605545e
the fetch will not fail anymore but I couldn't access the request body in the custom function probably because the content parser is not configured properly.
Another interesting thing is that if instead of changing the code in the
api-server
package I only comment it out and then addto my
api/src/server.ts
the fetch will still not work.Might be something to look into, it would be strange if the
addContentTypeParser
added inapi/src/server.ts
would not be applied.Another option I tried was installing
@fastify/multipart
and then registering it in myapi/src/server.ts
asserver.register(multipart)
but with no success at all.How do we reproduce the bug?
Create a simple custom function
On the frontend call the function as such and check the network tab to see the error message
What's your environment? (If it applies)
No response
Are you interested in working on this?
The text was updated successfully, but these errors were encountered: