question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Routing didn't work on SSR

See original GitHub issue
  • I’m submitting a …
- [ ] bug report
  • What modules are related to this Issue?

  • Do you want to request a feature or report a bug? A bug

  • What is the current behavior? The routing part didn’t work on SSR by typing directly in the browser the path or click on a tag to open a new link. By example: The first entry route is: user, inside user click to change the route to products works normally. From products go to products/:id works perfectly. But if I type in directly in the address bar the url by example: localhost:4200/products/1 it will never find out where is the route and turn out 504 error Gateway time out.

The routing part work normally before.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo. I will try to reproduce with a clone from universal-starter later

  • What is the expected behavior? Routing works normally

  • What is the motivation / use case for changing the behavior? The routing works before should also work for SSR

  • Please tell us about your environment:

  • Angular version: 5.2.5
  • Browser: all
  • Language: Typescript 2.6.2
  • OS: Window
  • Platform: NodeJS
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:4
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
MobackChetanKumarcommented, Jan 4, 2021

this.router.url is available in SSR in Angular11? the below code is not executing the Server side let routeName = ‘home’; if(this.isBrowser) { $(‘head’).find(‘script[type=“application/ld+json”]’).remove(); } if (this.router && this.router.url && this.router.url !== ‘/’) { if (this.router.url && this.router.url.indexOf(‘?’)) { routeName = this.router.url.split(‘?’)[0]; } else { routeName = this.router.url; } if (routeName && routeName.includes(‘/car-rental/’)) { routeName = routeName.replace(‘/car-rental/’, ‘’); routeName = routeName.replace(‘-car-rental’, ‘’); } if (routeName && routeName.includes(‘-one-way-car-rental’)) { routeName = routeName.replace(‘-one-way-car-rental’, ‘’); routeName = routeName.replace(‘/car-rental/’, ‘’); } } const script = document.createElement(‘script’); script.setAttribute(‘type’, ‘application/ld+json’); script.async = true; script.src = ‘assets/data/’ + routeName +‘-schema.js’; document.head.appendChild(script);

4reactions
TdoubleGcommented, May 11, 2019

Are there any new suggestions? Still have the same problem…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sveltekit routing doesn't work when SSR is disabled
I am using supabase for authentication. The $user store is undefined when I am trying to access it, so I decided to go...
Read more >
SSR Routing - How routing works - YouTube
A short video that walks you through an SSR application in Angular Universal that shows how http calls are made and how routes...
Read more >
nextjs client side routing and data fetching problems. - Reddit
nextjs client side routing and data fetching problems. I'm working on a website that needs good SEO, so I'm using nextjs for SSR....
Read more >
Implementing SSR in Next.js: Dynamic routing and prefetching
In addition to SSR support, Next.js offers link prefetching and dynamic routing ... of Next.js dynamic routes, let's work on the blog route:...
Read more >
Server Rendering with React and React Router - ui.dev
Now that we get the big picture, let's work on creating the foundation for what will become a server-rendered React with React Router...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found