@@ -39,6 +39,11 @@ export function githubToken(): string | undefined {
3939 return docs . githubToken || process . env . GITHUB_TOKEN || undefined
4040}
4141
42+ /** Production branch, resolved per request: content pushes skip redeploys (`vercel.json` `ignoreCommand`). */
43+ export function targetBranch ( ) : string {
44+ return process . env . VERCEL_GIT_COMMIT_REF || useRuntimeConfig ( ) . docs . github . branch || 'main'
45+ }
46+
4247// Branch + content directory → content commit SHA pointer, shared across every instance so only one
4348// pays for the GitHub API call per TTL window. See `refCacheDriver()` for the single-region assumption.
4449const refStorage = createStorage ( { driver : refCacheDriver ( ) } )
@@ -143,11 +148,6 @@ function pullAllowsPreview(pull: GitHubPullSummary): boolean {
143148 return ( pull . labels ?? [ ] ) . some ( ( label ) => label . name === PREVIEW_LABEL )
144149}
145150
146- /** The branch production serves — same resolution as `targetBranch()`, inlined to keep this module standalone. */
147- function baseBranch ( ) : string {
148- return process . env . VERCEL_GIT_COMMIT_REF || useRuntimeConfig ( ) . docs . github . branch || 'main'
149- }
150-
151151/**
152152 * Authorize a `/blob/:sha` preview and resolve it to the full 40-char SHA.
153153 *
@@ -200,7 +200,7 @@ export async function authorizePreviewSha(sha: string): Promise<string> {
200200 if ( ! allowed ) {
201201 try {
202202 const comparison = await $fetch < { status : string } > (
203- `https://api.github.com/repos/${ githubRepo ( ) } /compare/${ encodeURIComponent ( baseBranch ( ) ) } ...${ fullSha } ` ,
203+ `https://api.github.com/repos/${ githubRepo ( ) } /compare/${ encodeURIComponent ( targetBranch ( ) ) } ...${ fullSha } ` ,
204204 { headers : githubHeaders ( ) }
205205 )
206206 allowed = comparison . status === 'identical' || comparison . status === 'behind'
0 commit comments