Add deployment info debug section to admin panel#414
Merged
Conversation
Exposes four values that are easy to misconfigure or lose track of after a deploy: - PAPYRI_SITE (the configured canonical origin via Astro.site) - Request origin (what the server actually sees from the incoming request) - Adapter (node vs cloudflare, baked at build time) - Build commit (full SHA, baked at build time via vite.define) The commit hash is captured in astro.config.mjs via `git rev-parse HEAD` at bundle time, falling back to a PAPYRI_COMMIT env var (for Docker/CI builds without a .git directory) and then to "unknown". Both constants are injected as import.meta.env.PAPYRI_BUILD_COMMIT and PAPYRI_BUILD_ADAPTER via vite.define so they survive tree-shaking in the Cloudflare Workers bundle where process.env is not available at runtime.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new "Deployment" debug section to the admin panel that displays build-time and runtime configuration information, helping with debugging deployment issues.
Changes
Admin panel UI: Added a new "Deployment" section displaying:
PAPYRI_SITE— the canonical site origin (fromAstro.site)Build-time constants: Modified
astro.config.mjsto:git rev-parse HEADat build timePAPYRI_COMMITenvironment variable (for CI environments without.git)PAPYRI_BUILD_COMMITandPAPYRI_BUILD_ADAPTERintoimport.meta.envvia Vite'sdefineoption (works in both Node and Cloudflare Workers adapters)TypeScript types: Added
ImportMetaEnvinterface inenv.d.tsto type the new build-time constantsStyling: Added CSS for the deployment table and related elements (muted labels, monospace commit hash with word-breaking, italicized "(not set)" indicator)
Implementation details
The build-time constants are injected via Vite's
defineoption rather thanprocess.envbecause Cloudflare Workers bundles don't have access toprocess.envat runtime. Static string replacement ensures the values are available in both deployment targets.https://claude.ai/code/session_015U721nwm7oCgETQ2MFb8Fw