Nuxt 3 .output restore: missing integrity verification after deployment
0 reputation · 16 May 2020, 11:32 UTC
0 reputation · 16 May 2020, 11:32 UTC
When a Nuxt 3 application is redeployed, the standard approach is to copy the entire .output directory to the target host and start the Nitro server. However, Nuxt does not ship a checksum, signature, or manifest that can confirm the restored bundle matches the original build. This raises a question: how can we reliably verify that the recovered files are present and unmodified before launching the application?
Key constraints include:
.output folder; there is no built‑in integrity artifact.Unresolved behavior: should a custom pre‑deploy check be added, or can we rely on Nitro to surface issues at runtime?
.output (server entry, client chunks, public assets) are present and match expected hashes?nuxi build that can be used post‑restore to validate file integrity?34775 reputation · 16 May 2020, 17:05 UTC
Nuxt 3 and the Nitro engine do not provide a built-in checksum or manifest file to verify the integrity of the .output directory after it has been transferred to a production host. Because Nitro treats the filesystem as a source of truth at runtime, it does not perform a pre-flight validation of the bundle.
It is not advisable to rely on Nitro to surface deployment issues at runtime. The server's reaction to missing or corrupted files varies by location:
.output/server/index.mjs): If this file is missing or corrupted, the Node.js process will fail to start immediately with a MODULE_NOT_FOUND or syntax error..output/public/): If JS chunks or CSS files are missing, the server will start normally, but users will encounter 404 errors or silent failures when the browser attempts to load those assets.To ensure the restored bundle is complete and unmodified, you must implement a custom manifest check within your CI/CD pipeline. The most reliable method is generating a SHA-256 hash list immediately after nuxi build and verifying it on the target host before starting the server.
.output directory.
# Generate hashes for all files in .output
find .output -type f -exec sha256sum {} + > .output/integrity.sha256
.output folder (including the integrity.sha256 file) to the target host.# Verify files against the manifest
sha256sum -c .output/integrity.sha256
sha256sum command returns an exit code of 0.To confirm this workflow prevents silent failures, you can perform two tests in a staging environment:
.output/public and run the verification script; it should fail, preventing the deploy..output/server/index.mjs and run the script; it should fail.Diagnostic Detail Needed: Are you using a containerized deployment (e.g., Docker) or a direct filesystem transfer (e.g., rsync/scp)? If using Docker, integrity is typically guaranteed by the image layer hash, making a manual manifest redundant.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.