In my Angular 7 application, I have Angular Universal set up with Express and I am also utilizing Angular Routing. My goal is to have only the pre-login routes (marketing views) rendered server-side, while post-login routes are loaded using traditional client-side Angular loading.
Currently, I have successfully implemented this setup for routes navigated using router.navigate
or [routerLink]
. However, when a user refreshes the page in the browser, issues arise due to browser dependencies like cookies and local storage on certain routes.
The desired functionality is for routes excluded from server-side rendering to load as if Angular Universal is not present when directly navigated to or refreshed. Routes designated for server-side rendering should render on the server.
In my server.ts
file, I have the following line that uses Angular Universal for all routes:
app.get('*', (req, res) => {
res.render(join(DIST_FOLDER, 'browser', 'index.html'), { req });
});
I have attempted to specify the routes I want to use Universal for, but this approach results in a 404 error for all other routes. I believe I may be approaching this issue incorrectly.