Angular Universal: Prevent duplicate requests

Angular Universal: Prevent duplicate requests

The way angular universal works is that it makes the http calls on the server, loads the app with the data on the client, then it makes the http calls again on the client.

In order to prevent this, you need 2 things:

  • in app.module.ts add in imports the TransferHttpCacheModule
import {TransferHttpCacheModule} from '@nguniversal/common';
  • in the components, make sure that you make the http calls to the full path, for example: http://example.com/api/user and not just /api/user