Skip to content

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

@naveedahmed1

Description

@naveedahmed1

🐞 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 #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: 

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: serverIssues related to server-side renderingneeds reproductionThis issue needs a reproduction in order for the team to investigate further

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions