FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

refactor(platform-server): deprecate ServerXhr by alan-agius4 · Pull Request #69256 · angular/angular · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
16 changes: 16 additions & 0 deletions packages/platform-server/src/http.ts
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ import {RuntimeErrorCode} from './errors';
import {parseUrl} from './url';

@Injectable()
/**
* @deprecated Use the HttpClient fetch backend (by enabling `withFetch()`) instead.
* XHR support in `@angular/platform-server` is deprecated because the underlying `xhr2`
* library does not safely handle redirects (e.g. it can forward `Authorization` headers
* on cross-origin redirects and is susceptible to denial-of-service (DoS) via redirect loops).
*/
export class ServerXhr implements XhrFactory {
private xhrImpl: typeof import('xhr2') | undefined;

Expand All @@ -29,6 +35,16 @@ export class ServerXhr implements XhrFactory {
// server platform (via shims, etc).
private async ɵloadImpl(): Promise<void> {
if (!this.xhrImpl) {
if (typeof ngDevMode === 'undefined' || ngDevMode) {
console.warn(
'XHR support in `@angular/platform-server` is deprecated and will be removed ' +
'in a future version of Angular. It has known security and performance issues in server ' +
'environments, such as forwarding `Authorization` headers on cross-origin ' +
'redirects and susceptibility to denial-of-service (DoS) via redirect loops. ' +
'Please enable the HttpClient fetch backend instead by using `withFetch()`.',
);
}

const {default: xhr} = await import('xhr2');
this.xhrImpl = xhr;
}
Expand Down
Loading

Back | FazBrowse Home | New Git URL