W
Wasp-lang•4w ago
prof_mark

Payload too large

I am getting a payload too large error, directing me to this line: const response = await api.post(operationRoute.path, superjsonArgs) How can adjust the max payload size for uploads?
9 Replies
kapa.ai
kapa.ai•4w ago
Hi @prof_mark. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not contain information on how to adjust the max payload size for uploads in Wasp. I recommend checking the Wasp documentation or reaching out to the Wasp community for further assistance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @prof_mark, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
prof_mark
prof_mark•4w ago
I've tried following the directions here: https://wasp-lang.dev/docs/advanced/middleware-config#default-middleware-definitions I now have in my serverSetup.ts file:
import express from 'express';
import { type MiddlewareConfigFn } from 'wasp/server';

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// Increase payload size limit
middlewareConfig.set('express.json', express.json({ limit: '50mb' }));
middlewareConfig.set('express.urlencoded', express.urlencoded({ limit: '50mb', extended: true }));

return middlewareConfig;
};
import express from 'express';
import { type MiddlewareConfigFn } from 'wasp/server';

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// Increase payload size limit
middlewareConfig.set('express.json', express.json({ limit: '50mb' }));
middlewareConfig.set('express.urlencoded', express.urlencoded({ limit: '50mb', extended: true }));

return middlewareConfig;
};
but I now get an error:
[ Server!] [!] RollupError: src/server.ts (6:7): "default" is not exported by "../../../src/serverSetup.ts", imported by "src/server.ts".
[ Server!] https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
[ Server!] src/server.ts (6:7)
[ Server!] 4: import { config } from 'wasp/server'
[ Server!] 5:
[ Server!] 6: import setup from '../../../../src/serverSetup'
[ Server!] ^
[ Server!] [!] RollupError: src/server.ts (6:7): "default" is not exported by "../../../src/serverSetup.ts", imported by "src/server.ts".
[ Server!] https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
[ Server!] src/server.ts (6:7)
[ Server!] 4: import { config } from 'wasp/server'
[ Server!] 5:
[ Server!] 6: import setup from '../../../../src/serverSetup'
[ Server!] ^
Any ideas @kapa.ai
kapa.ai
kapa.ai•4w ago
Let me check the knowledge base for you. One moment! :books: ---------------------- The error message indicates that the setup function is not being exported from your serverSetup.ts file. The setup function is required by Wasp and is expected to be exported from your server setup file. In your serverSetup.ts file, you should have something like this:
import express from 'express';
import { type MiddlewareConfigFn, type ServerSetupFn } from 'wasp/server';

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// Increase payload size limit
middlewareConfig.set('express.json', express.json({ limit: '50mb' }));
middlewareConfig.set('express.urlencoded', express.urlencoded({ limit: '50mb', extended: true }));

return middlewareConfig;
};

export const setup: ServerSetupFn = async () => {
// Your setup code here
};
import express from 'express';
import { type MiddlewareConfigFn, type ServerSetupFn } from 'wasp/server';

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// Increase payload size limit
middlewareConfig.set('express.json', express.json({ limit: '50mb' }));
middlewareConfig.set('express.urlencoded', express.urlencoded({ limit: '50mb', extended: true }));

return middlewareConfig;
};

export const setup: ServerSetupFn = async () => {
// Your setup code here
};
The setup function is expected to be an async function and will be awaited before the server starts accepting any requests. It allows you to do any custom setup, e.g. setting up additional database/websockets or starting cron/scheduled jobs. You can read more about it in the Wasp documentation (https://wasp-lang.dev/docs/project/server-config#setupfn-extimport). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @prof_mark, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
prof_mark
prof_mark•4w ago
this didnt work. i am giving up for now and hopefully someonw has an idea
Filip
Filip•4w ago
Hey @prof_mark You used a named export in serverSetup.ts, but imported it using a default import in wasp. You should either use a default export in both files, or a named export in both files. With the code you showed here, the import in main.wasp must look like import { serverMiddleWareFn } from '@src/serverSetup.ts (notice the curly braces). But more importantly, what are you uploading that exceeds the payload limit?
prof_mark
prof_mark•4w ago
Awesome thank you!
MEE6
MEE6•4w ago
Wohooo @prof_mark, you just became a Waspeteer level 1!
prof_mark
prof_mark•4w ago
Was trying to send a 512x512 base 64 encoded image to open AI for their vision model. So really just needed to pass through. Ended up switching to sending the URL since I'm uploading the images to s3 anyway
Filip
Filip•4w ago
Ok, good choice! Yeah, that's pretty big for a post request 😅
Want results from more Discord servers?
Add your server