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.

platform-server - Changes introduced in 10.0.0-next.8 to convert relative URLs to absolute URLs breaks SSR

See original GitHub issue

🐞 bug report

Affected Package

The issue is caused by package @angular/platform-server

Is this a regression?

Yes, the previous version in which this bug was not present was: 10.0.0-next.6

Description

I recently updated my app from Angular 10.0.0-next.6 to 10.0.0-rc.0, after which I noticed strange behavior in SSR requests. After the update it broke the SSR for my app. I downgraded @angular/platform-server to 10.0.0-next.6 and everything started working fine.

I have an http interceptor, which:

  1. Converts the request url from relative to absolute urls in intercept method of my http interceptor.
  2. When on server, when I receive a response of the http request I add it to this.transferState.set(CACHE_KEY, event as any); and on client, I check if we already have the cached response, its served from cache otherwise request is sent to the server.

After the update if I open http://localhost:53189 in browser, which pulls data from https://www.mustakbil.com/ws/home/index, request seems to be working fine.

But if I open any other url e.g. http://localhost:53189/jobs/job/204182, when I open it in my browser the request goes to server which should fetch data from https://www.mustakbil.com/ws/jobs/job/204182, render it and return final response to client. But this doesn’t happen, and the SSR is broken.

In my component I make http request to /ws/jobs/job/204182 and then in intercept method of my interceptor I convert it to https://www.mustakbil.com/ws/jobs/job/204182.

After https://github.com/angular/angular/pull/37071 pull request , if I console log(req.url) in intercept method of my interceptor, before any modification to the request it shows /jobs/job/204182/ws/jobs/job/204182, whereas I expect it to show /ws/jobs/job/204182 because that’s what I passed from my component using this code this.http.get("/ws/jobs/job/204182").

🔬 Minimal Reproduction

I can add anyone from Angular team to a private repo.

🔥 Exception or Error


SSR is broken since the server is sending request to wrong url.

🌍 Your Environment

Angular Version:


Angular CLI: 10.0.0-rc.0
Node: 12.16.2
OS: win32 x64

Angular: 10.0.0-rc.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker
Ivy Workspace: <error>

Package                                    Version
--------------------------------------------------------------------
@angular-devkit/architect                  0.901.7
@angular-devkit/build-angular              0.1000.0-rc.0
@angular-devkit/build-optimizer            0.901.7
@angular-devkit/build-webpack              0.901.7
@angular-devkit/core                       10.0.0-rc.0
@angular-devkit/schematics                 10.0.0-rc.0
@angular/cdk                               10.0.0-next.1
@angular/fire                              6.0.0
@angular/google-maps                       10.0.0-next.1
@angular/material                          10.0.0-next.1
@angular/pwa                               0.1000.0-rc.0
@ngtools/webpack                           9.1.7
@nguniversal/module-map-ngfactory-loader   9.0.0-next.9
@schematics/angular                        10.0.0-rc.0
@schematics/update                         0.1000.0-rc.0
rxjs                                       6.5.5
typescript                                 3.9.3
webpack                                    4.41.2

Anything else relevant?

I am using aspnet-prerendering package to create createServerRenderer, should it cause issue?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
CaerusKarucommented, May 29, 2020

We’ve got a PR open to fix this. It’ll hopefully get into the next release.

1reaction
CaerusKarucommented, May 28, 2020

Domino only implements the href property (source). We’ll have to look at how we want to implement this to include the base URL and current route.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Absolute URLs converted to Relative URLs when saving item
The problem is that in the reporting engine, relative URLs are useless. ... the list to re-expand the relative URLs to absolutes and...
Read more >
Html::transformRootRelativeUrlsToAbsolute - Drupal 8.2.x
Converts all root-relative URLs to absolute URLs. Does not change any existing protocol-relative or absolute URLs. Does not change other relative URLs ......
Read more >
Convert relative to absolute URLs in Go - Stack Overflow
Yes, the standard library can do this with the net/url package. Example (from the standard library): package main import ( "fmt" "log" ...
Read more >
Change hreflang from relative URLs to absolute URLs
Solved: I'm in need of some help. I performed an audit of a client's HubSpot website with the help of the SEM Rush...
Read more >
Relative URLs in Webi - SAP Community
If you used absolute URL in the openDocument URL then it will always point to DEV report though you migrated both reports in...
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