Welcome. This is a sample post that the development seed creates, so the blog has something to show; it is replaced by real posts written in the admin.
What this blog is for
Notes on software engineering, web development, and building things. Short, practical, and written to be read in one sitting.
Code that reads well
Code is highlighted for both themes, with an optional file name, line numbers and highlighted lines:
export function proxy(request: NextRequest) {
const site = siteFromHost(request.headers.get("host"));
const url = request.nextUrl.clone();
url.pathname = `/sites/${site}${url.pathname}`;
return NextResponse.rewrite(url);
}A comparison
| Approach | Good for | Cost |
|---|---|---|
| One app, many hosts | Shared design and deploys | A routing layer |
| One app per site | Hard isolation | Three of everything |
The rich blocks
Steps
Step 01
Plan the move
Write down what runs where, and what each piece needs from the others.
Step 02
Switch the host
Point the proxy at the right site, then check each host with
curl.
Compare
Comparer
One app or three
| Aspect | One app per site | RecommandéOne app, many hosts |
|---|---|---|
| Shared design | Copied around | Built once |
| Deploys | Three pipelines | One pipeline |
| Isolation | Strong | Needs care |
A file tree
# The portfolio
# This blog
# Behind a sign-in
# Picks the site from the host
Code that types itself
export function siteFromHost(host: string) {
const name = host.split(".")[0];
return SITES.includes(name) ? name : "main";
}Several files
export const config = { matcher: "/((?!_next).*)" };A change
−const site = "main";+const site = siteFromHost(request.headers.get("host")); return NextResponse.rewrite(url);A terminal
# Start the dev server $ pnpm dev ready - started server on http://localhost:3000 $ curl -I http://blog.localhost:3000 HTTP/1.1 200 OK
A diagram
- Browser → Proxy: request
- Proxy → Main site: main host
- Proxy → Blog: blog host
A quiz
Question 1 / 2
What decides which site a request gets?
Where to next
Read the portfolio (s’ouvre dans un nouvel onglet), or follow the feed from the footer.
Commentaires