#How to shield sensitive functions? SSR not working

4 messages · Page 1 of 1 (latest)

solemn canopy
#

I want to remove some sensitive functions from the client and move them to SSR but it seems that doesn’t really help because most or all JS is still sent to the client…!

Has anyone got this working?

I know I can write logic in NodeJS but I’d rather keep everything in one Angular app.

hazy oriole
#

how are you trying to separate these functions from the client right now?

solemn canopy
#

They are currently client side but I want to render them serverside. How can I control where functions are rendered?

modest prawn
#

Create an injection token for your function, then provide separate implementations in the server.ts than in the client config.
Note though: Your app must work as a fully client-side rendered app, even with SSR. SSR is always optional in Angular and only applies to the initial page load. Further navigations happen entirely on the client and do not involve the SSR server.
If you really must keep things secret (such as an API key) you must hide them behind an API call and run an API server.