Skip to content

Commit

Permalink
fix: don't override user-agent in fetch if specified
Browse files Browse the repository at this point in the history
  • Loading branch information
SethFalco committed Mar 26, 2022
1 parent d41f8a5 commit 561cc8f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/next/server/web/sandbox/context.ts
Expand Up @@ -154,7 +154,10 @@ async function createModuleContext(options: {
const prevs = init.headers.get(`x-middleware-subrequest`)?.split(':') || []
const value = prevs.concat(options.module).join(':')
init.headers.set('x-middleware-subrequest', value)
init.headers.set(`user-agent`, `Next.js Middleware`)

if (!init.headers.has('user-agent')) {
init.headers.set(`user-agent`, `Next.js Middleware`)
}

if (typeof input === 'object' && 'url' in input) {
return fetch(input.url, {
Expand Down

0 comments on commit 561cc8f

Please sign in to comment.