3

I'm using Angular Universal + Prerender. Here are the packages:

  • "@nguniversal/express-engine": "^13.0.1"
  • "@angular/core": "13.0.1"

I prerender all my routes, I have a few ones.

The problem is that I run npm run prerender and I deploy my app to production.

When I navigate to https://myapp.com/products due to the prerendered files it add an extra slash at the end of the url, so the new url is https://myapp.com/products/, and Angular redirects me to the normal url again https://myapp.com/products.

In my server.ts file I have the following to redirect from http to https:

function requireHTTPS(req: any, res: any, next: any) {
if (!req.secure && req.get('x-forwarded-proto') !== 'https' && process.env.NODE_ENV !== "development") {
    return res.redirect(301, 'https://' + req.get('host') + req.url);
}
next();

}

And I use it this way (this has nothing to do with the extra slash):

server.use(requireHTTPS);

And I do not want to tell Express to do not do redirects. Just prevent prerender to add extra slash and make Angular to redirect.

I have lots of errors with SEO: Canonical points to redirect, 3XX redirect in sitemap, 3XX page receives organic traffic. And my site is not SEOlike.

I hope anyone can help. Thanks.

Amos Isaila
  • 286
  • 3
  • 14

0 Answers0