hapinessjs/ng-universal-module

This is not an issue but a doubt

tibinthomas opened this issue · 2 comments

If I need to add a new middle were in server.js file. How can I do it?

In case of pure express app I can do it as follows:

eg:

import * as cookieParser from 'cookie-parser';

app.use(cookieParser('Your private token'));

Is this is correct

onStart(): void {
this._httpServer.instance().app.use(cookieParser); // concerned line of code
console.log(Node server listening on ${this._httpServer.instance().info.uri});
}

@tibinthomas you can not use it like this. You have to use HttpInterceptor from Angular to get your cookie in the front application.

The SSR is just to render the content and the the cookie should come from an another API/server because you can't do something inside the server of SSR

Here an example of the creation of a HttpInterceptor with the injection of REQUEST object from the server