NGRX Application to SSR using NG Universal

56 Views Asked by At

Application not loading any UI and get this in terminal

HttpErrorResponse {
  headers: HttpHeaders {
    normalizedNames: Map(0) {},
    lazyUpdate: null,
    headers: Map(0) {}
  },
  status: 0,
  statusText: 'Unknown Error',
  url: 'https://localhost:7009/api/User/GetUsers',
  ok: false,
  name: 'HttpErrorResponse',
  message: 'Http failure response for https://localhost:7009/api/User/GetUsers: 0 Unknown Error',
  error: ProgressEvent {
    type: 'error',
    target: XMLHttpRequest {
         ....
    },
    currentTarget: XMLHttpRequest {
               ....
    },
    lengthComputable: false,
    loaded: 0,
    total: 0
  }
}

Firstly I run ng add @nguniversal/express-engine which created and modified some file then For Rest api I modified server.ts

server.get('/api/**', (req, res) => { });
server.get('*', (req, res) => {
    res.render(indexHtml, { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
});

Tried both

App Module

 BrowserModule.withServerTransition({ appId: 'serverApp' }),
 StoreModule.forRoot({ auth: authReducer }),
 EffectsModule.forRoot([AuthEffects]),

Using npm run dev:ssr to run application and after that opening local host its loading only Console check there's no error just load data not loading

0

There are 0 best solutions below