Http-server vs Serve: Run from dist directory
Tuesday, February 3, 2026
My team had to test an MFE repository locally. However, it's meant to be run from "dist" folder after build and package steps. I saw some recommendation online to use http-server (https://www.npmjs.com/package/http-server). So, I gave it a try and I managed to get it running really quick. And I quickly found issues too. After installation, I just need to run:
http-server dist
Accessing from the client, browser threw CORS error. Fixing that was quick with --cors option.
http-server --cors dist
Then, for somewhat reason, it didn't send Content-Type response header, so the client got it wrong when parsing the js file. I had to add -e js to set the default Content-Type to application/javascript.
http-server -e js --cors dist
It's not too bad, but I'm looking for a little simpler solution and I had good experience with serve (https://www.npmjs.com/package/serve). With serve, after installation, I just need to run:
serve dist
Same case with http-server, I need to enable CORS by adding --cors option, so it becomes:
serve --cors dist
However, it automatically sends the right Content-Type response header.