Kapsule Field NotesKapsule Field Notes

The build that baked in the old address

Sun Mar 08

Some environment variables are read when the software starts. Others are compiled into it. Confusing the two moves a broken site.

A framework that ships JavaScript to the browser cannot read your server environment from the browser. So it substitutes the values at BUILD time, writing them into the emitted bundle as literal strings.

Move the application to a new host, carry the old environment file across, rebuild, and every one of those literals is still the old address. The server renders correctly, because the server does read the environment. The moment a visitor clicks something that was compiled, they go back to the machine you were trying to leave.

The check that catches it is embarrassingly simple: after the build, search the emitted bundle for the old hostname. If it is there, the build is wrong, no matter what the page looks like.

Back to all notes