When I started working on launching web app, I wanted to try something new: deploy two microservices with a connected strategy.
- One repo for backend (API + IaC).
- One repo for frontend (Next.js app).
- A CodePipeline for backend that provisions Amplify and references the frontend repo.
- On commit, Amplify picks up changes and hosts the site.
This was my first real microservice deployment, connecting two services in one flow. I was excited, but also a bit lost.
โก The Confusion Phase
At first, I thought: โFrontend is just Next.js, why not use next export and push static files? Amplify loves static hosting!โ
So I configured it that way. The build succeeded, the deployment was lightning fast.
But when I opened the siteโฆ disaster:
- Dynamic routes didnโt work
- API routes were missing
- Auth and SSR pages broke
That was my first microservice reality check: deployment strategy matters more than just โgetting it running.โ
๐ The Breakthrough: Standalone Mode
After a lot of reading and trial-and-error, I discovered Next.js standalone mode.
// next.config.js
const nextConfig = {
output: 'standalone',
};
module.exports = nextConfig;
Instead of exporting static HTML, this packaged a minimal Node.js server bundle. When Amplify deployed it, suddenly everything worked:
- โ SSR pages
- โ Dynamic routes
- โ API routes
- โ Hybrid static + dynamic content
Thatโs when I realized: I donโt need to separate static vs dynamic apps โ standalone mode handles both.
๐ ๏ธ My Deployment Strategy
Hereโs how I structured it:
- Backend pipeline (CodePipeline) โ deploys infrastructure + creates Amplify app referencing frontend repo.
-
Frontend repo โ contains
buildspec.yml+standaloneNext.js config. - Amplify โ automatically builds and deploys on commit.
This way, backend and frontend stay decoupled as microservices, but still integrate in the pipeline.
๐ Lessons from My First Microservice Deployment
- Donโt force static exports on dynamic apps โ it breaks SSR and APIs.
- Standalone mode is the right fit for Amplify + Next.js microservices.
- Keep backend and frontend pipelines separate โ but connect them smartly through IaC.
- The right deployment strategy saves you from debugging chaos later.
โจ Final Thought
This was my first microservice deployment where I connected backend and frontend pipelines. I was confused, tried the wrong approach, but eventually found the right strategy.
Now, the pipeline runs smooth: backend infra deploys, Amplify auto-builds the frontend, and Dev/Prod stages are stable.
Looking back, I realize the real win wasnโt just hosting the app it was learning how to design a deployment strategy that connects services the right way.
Top comments (0)