Mihai Marinescu
Mihai Marinescu's Blog

Mihai Marinescu's Blog

Angular Universal: Prevent duplicate requests

Angular Universal: Prevent duplicate requests

Mihai Marinescu's photo
Mihai Marinescu
·Oct 9, 2021·

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
 
Share this