question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to set Referrer-Policy HTTP header using the Angular HTTP client

See original GitHub issue

Bug Report

Affected Package

The issue is caused by package @angular/common/http

Is this a regression?

Unknown. Most likely not.

Description

Is not possible to change the Referrer-Policy HTTP header using the Angular HTTP client.

Minimal Reproduction

See https://stackblitz.com/edit/angular-ivy-abg9st?file=src%2Fapp%2Fapp.component.ts or see code snippet below:

const url = `https://jsonplaceholder.typicode.com/todos/1`;

return this.httpClient.get(url, {
  headers: new HttpHeaders({
    'Referrer-Policy': 'no-referrer'
  })
});

Exception or Error

The Referer and Referrer-Policy HTTP headers are unchanged.

We expect the Referer header to be hidden and Referrer Policy to be no-referrer

Expected:

Referrer Policy: no-referrer

Actual:

Referrer Policy: origin-when-cross-origin

Your Environment

Angular Version:


Angular CLI: 11.2.6
Node: 14.15.4
OS: darwin x64

Angular: 11.2.7
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router
Ivy Workspace: Yes

Package                          Version
----------------------------------------------------------
@angular-devkit/architect        0.1102.6
@angular-devkit/build-angular    0.1102.6
@angular-devkit/core             11.2.6
@angular-devkit/schematics       11.2.6
@angular-devkit/schematics-cli   0.1102.6
@angular/cdk                     11.2.6
@angular/cli                     11.2.6
@angular/fire                    6.1.4
@angular/flex-layout             11.0.0-beta.33
@angular/material                11.2.6
@nguniversal/builders            11.2.1
@nguniversal/express-engine      11.2.1
@schematics/angular              11.2.6
@schematics/update               0.1102.6
ng-packagr                       11.2.4
rxjs                             6.6.7
typescript                       4.1.5

Anything else relevant?

The issue persists across browsers.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

12reactions
angular-robot[bot]commented, Jun 5, 2021

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we’ll move it to our consideration list.

You can find more details about the feature request process in our documentation.

0reactions
angular-automatic-lock-bot[bot]commented, Mar 4, 2022

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set the Referrer-Policy HTTP header with the Angular ...
How can we set the Referrer-Policy HTTP header when using Angular's HTTP Client? I've tried setting it below but it does not work:...
Read more >
Referrer-Policy - HTTP - MDN Web Docs
The Referrer-Policy HTTP header controls how much referrer information (sent with the Referer header) should be included with requests.
Read more >
Referer and Referrer-Policy best practices - web.dev
Best practices to set your Referrer-Policy and use the referrer in incoming requests. ... HTTP request including a Referer header.
Read more >
Angular CORS Guide: Examples and How to Enable It
Understand what CORS is, why it occurs and how to enable it inside an Angular application using a proxy server.
Read more >
HTTP headers | Referrer-Policy - GeeksforGeeks
The Referrer Policy HTTP header sets the parameter for amount of information sent along with Referrer Header while making a request.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found