Skip to content

fix: mark the internal fetch helpers as server-only - #25

Merged
maslianok merged 1 commit into
mainfrom
fix/server-only-internal-fetch
Sep 6, 2026
Merged

maslianok merged 1 commit into
mainfrom
fix/server-only-internal-fetch

Conversation

@maslianok

Copy link
Copy Markdown
Contributor

lib/signed-fetch.ts and lib/graphql/request.ts are server-side utilities — every importer is a route handler, RSC page/layout, sitemap, badge renderer or a graphql/helpers/* module, and no client component pulls them in. Both nevertheless carried a 'use server' directive, which registers each export as a server action and so makes it callable from outside rather than only from server code. That was not the intent of either module.

This swaps the directive for import 'server-only', which expresses the same "server code only" constraint without publishing anything, and turns a future client-side import into a build error rather than a silently exposed endpoint.

Verification

  • tsc --noEmit clean; pnpm build completes.
  • Scanned all 43 per-page server-reference-manifest.json files. Before: both exports appear as registered references across them. After: neither appears.
  • Aggregate manifest drops from 55 registered server references to 53 — matching the two removed.
  • Neither export appears anywhere in .next/static.

No behaviour change: the modules are called exactly as before by the same server-side callers.

🤖 Generated with Claude Code

Both modules are server-side utilities that no client component
imports, but each carried a 'use server' directive. That registers
every export as a server action, which makes them callable from
outside rather than only from server code — not what these modules
are for.

Replace the directive with `import 'server-only'`. It enforces the
same intent and turns any future client-side import into a build
error instead of silently publishing an endpoint.

Verified against the build manifests: registered server references
drop from 55 to 53, and neither export appears in any per-page
manifest or in the client bundles.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused server-only changes have no unresolved issues and passed the reported checks.

Pull request overview

Reclassifies internal fetch utilities as server-only modules without exposing them as Server Actions.

Changes:

  • Replaces 'use server' with import 'server-only'.
  • Adds and locks the server-only dependency.
File summaries
File Description
pnpm-lock.yaml Locks the new dependency.
package.json Declares the server-only dependency.
lib/signed-fetch.ts Restricts signed requests to server code.
lib/graphql/request.ts Restricts GraphQL requests to server code.
Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file
  • Files reviewed: 3/4 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@maslianok
maslianok merged commit 81fcbc5 into main Sep 6, 2026
1 check passed
@maslianok
maslianok deleted the fix/server-only-internal-fetch branch September 6, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants