templates(openui-cloud): send openui-template/nextjs User-Agent on server fetches - #1259
Closed
devin-ai-integration[bot] wants to merge 2 commits into
Closed
devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
…tches Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This branch was successfully deployed
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.
What
Apps scaffolded from the
openui-cloudtemplate now sendUser-Agent: openui-template/nextjson outbound server-side requests, so template traffic is identifiable.Changes
src/instrumentation.ts(the Next.js startup hook:register()runs once before any route is served). It wrapsglobalThis.fetchand sets theUser-Agentheader, merging existingRequest/initheaders first:Because it patches global fetch, it covers the raw
fetchin/api/frontend-tokenand 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 owninstrumentation.ts, so this applies to all of them.Test Plan
next dev, pointed/api/frontend-tokenand/api/chatat a local echo server, and confirmed both the plainfetchand theopenaiSDK requests arrived withUser-Agent: openui-template/nextjs.tsc --noEmit,eslint, andprettier --checkpass.Checklist
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