0

With angular 7 universal, I'm run on client server with command:

npm run build:ssr && npm run serve:ssr

I have homepage with list products and product-detail with paramn getting from homepage.

In homepage.ts, to redirect to product-detail, I'm using:

this.router.navigate(['/product-detail', id]);

On brower, the url like: http://localhost:4000/product-detail/1

And product-detail page still loading But when I refresh page or access with url on brower, it not working.

I'm don't know how to fix that. Anyone can help? Please.

David
  • 33,444
  • 11
  • 80
  • 118
Duy Huỳnh
  • 141
  • 2
  • 10
  • Any error in the console server side? Or client side? – David May 27 '19 at 09:38
  • Hi David. I try to add console.log('Check flow') in product-detail.component.ts - In case : this.router.navigate(['/product-detail', id]); - It log in cosole of browser.But in case access in url brower, It show in console terminal of visual code. – Duy Huỳnh May 27 '19 at 10:18
  • But in the console where you run `npm run serve:ssr`, you have no errors? – David May 27 '19 at 12:03
  • It work fine, hard to know it – Duy Huỳnh May 27 '19 at 12:48
  • @David I add console.log(errs) after call API has errors "Error: The XMLHttpRequest compatibility library was not found. - code: 'auth/internal-error' - message: 'The XMLHttpRequest compatibility library was not found.' " – Duy Huỳnh May 27 '19 at 14:21
  • Are you using firebase? That may help https://stackoverflow.com/questions/41214625/firebase-node-js-error-the-xmlhttprequest-compatibility-library-was-not-foun – David May 28 '19 at 06:50
  • Hi @David, I find solution in my case from https://fireship.io/lessons/angular-universal-firebase/ - I add 2 line (global as any).WebSocket = require('ws'); (global as any).XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; in serve.ts --- Now, I tried to setup dynamic meta tag with title and description fetch from DB. But facebook crawler only know meta tag from index.html. Do you have solution for this? Thanks you. – Duy Huỳnh May 28 '19 at 17:01
  • In chrome browser, when F12 to check element I can see meta tag update. But when I viewpage source, nothing to change. – Duy Huỳnh May 29 '19 at 03:30
  • That's a different question – David May 29 '19 at 07:04
  • @David, maybe I dont pass that issue. When I using httpClient to fetch data from API, it alway errors. Message errors look like: (node:16776) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead ----- "ProgressEvent { type: 'error', target: XMLHttpRequest {..............." – Duy Huỳnh May 29 '19 at 07:14
  • I think my case like https://stackoverflow.com/questions/49355650/angular5-server-side-rendering-external-api-data-service-does-not-work-in-ssr – Duy Huỳnh May 29 '19 at 07:30

0 Answers0