• 개요
@angular/common/http

HTTP_TRANSFER_CACHE_ORIGIN_MAP

상수
안정화

If your application uses different HTTP origins to make API calls (via HttpClient) on the server and on the client, the HTTP_TRANSFER_CACHE_ORIGIN_MAP token allows you to establish a mapping between those origins, so that HttpTransferCache feature can recognize those requests as the same ones and reuse the data cached on the server during hydration on the client.

API

    
      const HTTP_TRANSFER_CACHE_ORIGIN_MAP: InjectionToken<Record<string, string>>;
    
    

설명

If your application uses different HTTP origins to make API calls (via HttpClient) on the server and on the client, the HTTP_TRANSFER_CACHE_ORIGIN_MAP token allows you to establish a mapping between those origins, so that HttpTransferCache feature can recognize those requests as the same ones and reuse the data cached on the server during hydration on the client.

IMPORTANT: The HTTP_TRANSFER_CACHE_ORIGIN_MAP token should only be provided in the server code of your application (typically in the app.server.config.ts script). Angular throws an error if it detects that the token is defined while running on the client.

사용 시 참고사항

When the same API endpoint is accessed via http://internal-domain.com:8080 on the server and via https://external-domain.com on the client, you can use the following configuration:

// in app.server.config.ts
{
    provide: HTTP_TRANSFER_CACHE_ORIGIN_MAP,
    useValue: {
        'http://internal-domain.com:8080': 'https://external-domain.com'
    }
}
상세 내용으로 이동