You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to send a payload using POST method to a custom endpoint, and I get PayloadTooLargeError how to extend the default size limit if this is not a bug?
@pevey, I knew that the problem was with the express server. Even though I was making changes to the index.js file in the base directory, I couldn't see any of the changes applied. This was because when you run medusa develop , it doesn't use the index.js server, causing my code to not work. To resolve the issue, I had to run index.js using node index.js .
Here is the modified index.js that resolved the issue, in case anyone else encounters this problem.
const{ json, urlencoded }=require("body-parser");constexpress=require("express")const{ GracefulShutdownServer }=require("medusa-core-utils")constloaders=require("@medusajs/medusa/dist/loaders/index").default;(async()=>{asyncfunctionstart(){constapp=express()app.use(json({limit: '10mb'}))app.use(urlencoded({limit: '10mb',extended: true}))constdirectory=process.cwd()try{const{ container }=awaitloaders({
directory,expressApp: app})constconfigModule=container.resolve("configModule")constport=process.env.PORT??configModule.projectConfig.port??9000constserver=GracefulShutdownServer.create(app.listen(port,(err)=>{if(err){return}console.log(`Server is ready on port: ${port}`)}))// Handle graceful shutdownconstgracefulShutDown=()=>{server.shutdown().then(()=>{console.info("Gracefully stopping the server.")process.exit(0)}).catch((e)=>{console.error("Error received when shutting down the server.",e)process.exit(1)})}process.on("SIGTERM",gracefulShutDown)process.on("SIGINT",gracefulShutDown)}catch(err){console.error("Error starting server",err)process.exit(1)}}awaitstart()})()
Bug report
Describe the bug
I'm trying to send a payload using POST method to a custom endpoint, and I get
PayloadTooLargeError
how to extend the default size limit if this is not a bug?System information
Medusa version (including plugins):
Node.js version:v16.20.0
Database: postgresql
Operating system: macOS 13
Browser (if relevant):
Steps to reproduce the behavior
Expected behavior
There should be a way to extend the post method payload limit.
Code snippets
I tried to pass limit to body parser json function but didn't resolve the issue.
The text was updated successfully, but these errors were encountered: