Why I Abandoned Vercel's 'serve' for 'http-server'
Today I want to share a pragmatic lesson on Tool Selection from the early static HTML/JS iteration of this portfolio (prior to migrating to Next.js).
When previewing those early plain HTML/JS pages locally, I initially reached for Vercel's serve package. While serve is great for previewing pre-built Single-Page Application (dist/) bundles, its opinionated URL rewriting clashed with our production Nginx static file layout.
The "Clean URL" Mismatch
By default, serve enables Clean URLs: if you navigate to /blog.html, it issues a 301 redirect stripping the extension to /blog, and internally resolves /blog back to blog.html.
That behavior is convenient when your production host uses identical rewrite rules, but it clashed with two realities of our early setup:
- Local (
serve): Automatically stripped.htmlextensions via301redirects, dropping or altering query strings like?id=...when combined with folder collisions. - Production (
Nginx): Served explicit.htmlfiles without automatic extensionless rewrites unless customtry_filesdirectives were added. - Configuration Friction: Writing custom
serve.jsonrules just to disable the tool's opinionated defaults meant fighting the local server instead of mirroring plain static file behavior.
Choosing a Predictable Tool
Instead of layering configuration workarounds onto serve, I switched local static previews to http-server:
npx http-server . -p 8080 -c-1
-c-1: SetsCache-Control: no-cache, preventing the browser from serving stale assets via304 Not Modifiedcache hits during active editing.- Predictable File Mapping: No implicit extension-stripping redirects. Requesting
/blog.htmlserves/blog.htmlverbatim, matching basic static file servers 1-to-1.
Leveling Up as an Engineer
Coming from enterprise .NET, we are used to comprehensive frameworks with rich conventions. In lightweight static tooling, however, unasked-for magic creates environment parity bugs.
Sometimes the more feature-rich tool introduces friction simply because its opinions don't match your deployment target. Recognizing when to step down to a simpler, transparent tool is a hallmark of practical engineering.