Render free tier services sleep after some 15-20 minutes of inactivity. First user request may take 30-50 seconds to wake up the backend. If you had to wait almost a minute stuck at Loading Page, the site isn’t broken, its the cold start.
Render gives you URLs like your-app.onrender.com and .onrender.com which is a public suffix domain. Browsers block third-party cookies between different onrender.com subdomains for security reasons.
It took me 7 commits and multiple redeployments to understand the issue. I thought the issue is in the code, tried all approaches then I started to debug within the browser and found that the cookie is not being saved in the browser. There were sessions break (401 Unauthorized) even though login succeeded. Only solution was to buy a custom domain and host the frontend and backend on the same custom domain.
I googled it, found the issue in render’s community page. Figured out the issue isn’t from my side.
Source: https://community.render.com/t/cookies-domain-issue-fullstackapp/19105
After I faced the issues, I tried deploying my backend to EC2. I faced another issue. Docker Image for Node.js + TS + S3 + MongoDB connection becomes very heavy.
EC2 Free Tier t2.micro has only 1GB RAM. When Docker tries to npm run build, Node.js runs out of memory. Heap out of memory error happens. Docker container crashes during build itself. Building TypeScript projects with Docker requires atleast 2GB RAM, ideally 4GB.
The only solution is to pay for a bigger EC2 instance - not free.