R
Railway3mo ago
Jon

Nextjs app not being compressed and slower than expected

Looking for options to move away from hosting nextjs on vercel. Was able to deploy my nextjs app to railway without any errors but it seems to be much slower than when deployed on vercel or cloudflare. When I run pagespeed on it, it flags text compression as an issue on railway but not on the other deployments. Also tested out deploying the same app on Render and that does not have this issue. I also noticed that pagespeed insights also indicate that the unused javascript is much larger on the railway deployment than any of the others. 700mb vs 130mb. Not sure what the issue is. In the images, railway is the one with the text compression flag and larger unused javascript. The other image is of the Render deployment.
No description
No description
11 Replies
Percy
Percy3mo ago
Project ID: 23257359-c206-42e7-8add-b74bf5caac64
Jon
JonOP3mo ago
23257359-c206-42e7-8add-b74bf5caac64
Brody
Brody3mo ago
railway is only ever going to run your code / app as-is, so any issues in this regard would be due to missconfigurations on your part. for example, maybe you are having railway run next in development mode
Jon
JonOP3mo ago
Hmm, I did follow the guide for nextjs in the railways docs. I simply pointed at the github repo for my app and it was pretty simple to deploy. I did the exact same thing on Render and Vercel. Just pointed to the exact same github repo. All have the same env variables as well and running on the same node version. and based on logs, it is running in production mode through next build -> next start
Brody
Brody3mo ago
yep as mentioned, railway will only ever run your code as-is, vercel and render do a lot of hand holding in this regard
Jon
JonOP3mo ago
I looked through the logs and I don't see anything out of the normal for the deployment. I did see other posts in regards to railway not compressing but I thought next automatically compressed during the build process?
Brody
Brody3mo ago
nothing to do with railway here, the user would be responsible for setting up the next project with the correct build settings I would recommend to read next's docs for improvements you could make to your config
Jon
JonOP3mo ago
Okay yeah that was on me. Seems its a vercel specific thing where nextjs is automatically compressed. Does not apply to other hosts. Resolved this by setting up a cloudflare proxy which automatically compresses. Sidenote: Deploying nextjs on railway was very easy. Might actually switch over now that I resolved this.
Brody
Brody3mo ago
glad to hear that, deploying next on railway is easy as long as you are aware oh how railway works (or doesn't work)
Jon
JonOP3mo ago
Unrelated but quick question: I wouldn't be able to set a custom domain for both a www.website.com and website.com unless I upgrade to a paid tier right?
Brody
Brody3mo ago
correct, 2 custom domains is a hobby plan thing but on the bright side, you'd eventually need to upgrade anyway
Want results from more Discord servers?
Add your server