Angular Universal: Prevent duplicate requests

Mihai MarinescuMihai Marinescu
1 min read

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
0
Subscribe to my newsletter

Read articles from Mihai Marinescu directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mihai Marinescu
Mihai Marinescu