#middleware file too heavy

16 messages · Page 1 of 1 (latest)

mortal spoke
#

The error that stops my deployment says src/middleware is 3.08MB but your current plan allows a maximum file size of 1MB All I have is this code. I have no error in development but when I push to prduction I get this error.

Middleware’s file: https://sourceb.in/RoeRxYEDL9
getUser function: https://sourceb.in/hkg4tnP26A

waxen micaBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

pure creek
#

What happens if you just define the getUser function inside the middleware

mortal spoke
#

I don’t know. I can try but is it because it’s in a separate file?

pure creek
#

I'm just throwing out ideas for troubleshooting to narrow things down

#

Maybe it's because it's in the separate file but it should be smart enough to split things out for you. Maybe it's whatever your "constants" variable is

sly mountain
#

The only thing you aren't really showing is what is in ./utils/api. Although it should be code split, you are using file-scoped variables from within the getUser function which could confuse things

#

for example, 'constants' could be coming with a lot of other baggage

mortal spoke
mortal spoke
sly mountain
#

so, another easier idea might be to export the strings directly instead of wrapped in an object

#

like export const api_endpoint = "hello world"

mortal spoke
sly mountain
#

yes, that would be easy for code splitting to deal with

#

and you could actually use a synthetic import to get a similar effect if you moved everything to separate exports.

#

In /utils/api

export const api_route="test"
export const key="secret"