Skip to content

templates(openui-cloud): send openui-template/nextjs User-Agent on server fetches - #1259

Closed
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1790657771-template-user-agent
Closed

devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1790657771-template-user-agent

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

What

Apps scaffolded from the openui-cloud template now send User-Agent: openui-template/nextjs on outbound server-side requests, so template traffic is identifiable.

Changes

  • Add src/instrumentation.ts (the Next.js startup hook: register() runs once before any route is served). It wraps globalThis.fetch and sets the User-Agent header, merging existing Request/init headers first:
globalThis.fetch = (input, init) => {
  const headers = new Headers(input instanceof Request ? input.headers : undefined);
  new Headers(init?.headers).forEach((v, k) => headers.set(k, v));
  headers.set("User-Agent", "openui-template/nextjs");
  return baseFetch(input, { ...init, headers });
};

Because it patches global fetch, it covers the raw fetch in /api/frontend-token and the SDK clients (openai, @ai-sdk/openai, @langchain/openai) used by the default route and overlays, overriding their default UA (e.g. OpenAI/JS x.y). No overlay ships its own instrumentation.ts, so this applies to all of them.

Test Plan

  • Verified locally: scaffolded a copy of the template, ran next dev, pointed /api/frontend-token and /api/chat at a local echo server, and confirmed both the plain fetch and the openai SDK requests arrived with User-Agent: openui-template/nextjs.
  • tsc --noEmit, eslint, and prettier --check pass.

Checklist

  • I linked a related issue, if applicable
  • I updated docs/README when needed
  • I considered backwards compatibility

Link to Devin session: https://app.devin.ai/sessions/649e446c800a420c891a8c304134315a
Open in Devin Desktop: https://app.devin.ai/desktop/session/649e446c800a420c891a8c304134315a?variant=devin
Requested by: @zahlekhan

…tches

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openui-docs Ready Ready Preview Sep 29, 2026 5:37am UTC

Request Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration devin-ai-integration Bot changed the title templates(openui-cloud): send OpenUI-template User-Agent on server fetches templates(openui-cloud): send openui-template/nextjs User-Agent on server fetches Sep 29, 2026

This branch was successfully deployed

1 active deployment
Preview — ebae7a11 Deployed Sep 29, 2026 by vercel[bot]
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.

1 participant