{"record":{"id":"3be568ff4b1a197a","repo":"microsoft/playwright","slug":"referer-is-already-specified-as-extra-http-heade","errorCode":null,"errorMessage":"\"referer\" is already specified as extra HTTP header","messagePattern":"\"referer\" is already specified as extra HTTP header","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/frames.ts","lineNumber":704,"sourceCode":"    };\n    this._redirectedNavigations.set(documentId, data);\n    data.gotoPromise.finally(() => this._redirectedNavigations.delete(documentId));\n  }\n\n  async goto(progress: Progress, url: string, options: types.GotoOptions = {}): Promise<network.Response | null> {\n    const constructedNavigationURL = constructURLBasedOnBaseURL(this._page.browserContext._options.baseURL, url);\n    return this.raceNavigationAction(progress, async () => this.gotoImpl(progress, constructedNavigationURL, options));\n  }\n\n  async gotoImpl(progress: Progress, url: string, options: types.GotoOptions): Promise<network.Response | null> {\n    const waitUntil = verifyLifecycle('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);\n    progress.log(`navigating to \"${url}\", waiting until \"${waitUntil}\"`);\n    const headers = this._page.extraHTTPHeaders() || [];\n    const refererHeader = headers.find(h => h.name.toLowerCase() === 'referer');\n    let referer = refererHeader ? refererHeader.value : undefined;\n    if (options.referer !== undefined) {\n      if (referer !== undefined && referer !== options.referer)\n        throw new Error('\"referer\" is already specified as extra HTTP header');\n      referer = options.referer;\n    }\n    url = helper.completeUserURL(url);\n\n    const navigationEvents: NavigationEvent[] = [];\n    const collectNavigations = (arg: NavigationEvent) => navigationEvents.push(arg);\n    this.on(Frame.Events.InternalNavigation, collectNavigations);\n    let navigateResult;\n    try {\n      navigateResult = await progress.race(this._page.delegate.navigateFrame(this, url, referer));\n    } finally {\n      this.off(Frame.Events.InternalNavigation, collectNavigations);\n    }\n\n    let event: NavigationEvent;\n    if (navigateResult.newDocumentId) {\n      const predicate = (event: NavigationEvent) => {\n        // We are interested either in this specific document, or any other document that","sourceCodeStart":686,"sourceCodeEnd":722,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/frames.ts#L686-L722","documentation":"page.goto(url, { referer }) conflicts with an extraHTTPHeaders 'referer' already set on the page/context. If both are present and differ, goto throws rather than silently letting one win.","triggerScenarios":"Setting extraHTTPHeaders with a 'referer' (case-insensitive) on the context or page, and then also passing options.referer to page.goto with a different value.","commonSituations":"Reusing a context that sets a global referer for telemetry and then overriding per-navigation; migrating from context-level referer to per-goto referer without removing the header; case variants ('Referer' vs 'referer').","solutions":["Remove the referer from extraHTTPHeaders if you intend to set it per-goto.","Or stop passing options.referer and rely solely on the extra header.","Ensure the two values are identical if both must be set."],"exampleFix":"// before\nconst ctx = await browser.newContext({ extraHTTPHeaders: { referer: 'https://a.test' } });\nawait page.goto(url, { referer: 'https://b.test' }); // mismatch -> throws\n// after: pick one source of truth\nawait page.goto(url, { referer: 'https://b.test' }); // and drop the extra header","handlingStrategy":"validation","validationCode":"// Reconcile referer sources before goto\nconst headers = page.context().options()?.extraHTTPHeaders ?? {};\nconst ctxReferer = headers['referer'] ?? headers['Referer'];\nif (ctxReferer && gotoReferer && ctxReferer !== gotoReferer) {\n  throw new Error('referer conflict');\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Choose a single referer strategy (context-level OR per-goto), not both.","When refactoring, search for 'referer' case-insensitively in header config."],"tags":["navigation","referer","headers","validation"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}