Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular SSR with SSL is broken with the http client get for relative url #26652

Closed
1 task
SetoKaiba opened this issue Dec 12, 2023 · 3 comments · Fixed by #26658
Closed
1 task

Angular SSR with SSL is broken with the http client get for relative url #26652

SetoKaiba opened this issue Dec 12, 2023 · 3 comments · Fixed by #26658

Comments

@SetoKaiba
Copy link

SetoKaiba commented Dec 12, 2023

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

httpClient.get('assets/test.json')

It's working without SSL.
But it is broken after I use SSL.
The url becomes https://undefined/assets/test.json.

Minimal Reproduction

httpClient.get('assets/test.json')

Exception or Error

ERROR HttpErrorResponse {
  headers: _HttpHeaders {
    normalizedNames: Map(0) {},
    lazyUpdate: null,
    headers: Map(0) {}
  },
  status: 0,
  statusText: 'Unknown Error',
  url: 'https://undefined/assets/test.json',
  ok: false,
  name: 'HttpErrorResponse',
  message: 'Http failure response for https://undefined/assets/test.json: 0 undefined',
  error: TypeError: fetch failed
      at node:internal/deps/undici/undici:12442:11
      at _ZoneDelegate.invoke (e:/WebstormProjects/ciyuan-frontend/node_modules/zone.js/fesm2015/zone-node.js:368:26)
      at Object.onInvoke (e:/WebstormProjects/ciyuan-frontend/node_modules/@angular/core/fesm2022/core.mjs:14695:33)
      at _ZoneDelegate.invoke (e:/WebstormProjects/ciyuan-frontend/node_modules/zone.js/fesm2015/zone-node.js:367:52)
      at _Zone.run (e:/WebstormProjects/ciyuan-frontend/node_modules/zone.js/fesm2015/zone-node.js:129:43)
      at eval (e:/WebstormProjects/ciyuan-frontend/node_modules/zone.js/fesm2015/zone-node.js:1188:36)
      at _ZoneDelegate.invokeTask (e:/WebstormProjects/ciyuan-frontend/node_modules/zone.js/fesm2015/zone-node.js:402:31)
      at eval (e:/WebstormProjects/ciyuan-frontend/node_modules/@angular/core/fesm2022/core.mjs:14369:55)
      at AsyncStackTaggingZoneSpec.onInvokeTask (e:/WebstormProjects/ciyuan-frontend/node_modules/@angular/core/fesm2022/core.mjs:14369:36)
      at _ZoneDelegate.invokeTask (e:/WebstormProjects/ciyuan-frontend/node_modules/zone.js/fesm2015/zone-node.js:401:60) {
    cause: Error: getaddrinfo ENOTFOUND undefined
        at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) {
      errno: -3008,
      code: 'ENOTFOUND',
      syscall: 'getaddrinfo',
      hostname: 'undefined'
    }
  }
}

Your Environment

Node.js version v21.4.0 detected.                                                                                                                                              
Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/previous-releases/.

     _                      _                 ____ _     ___ 
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | | 
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | | 
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/                                        
                                                             

Angular CLI: 17.0.6       
Node: 21.4.0 (Unsupported)
Package Manager: npm 10.2.4
OS: win32 x64

Angular: 17.0.6
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.6
@angular-devkit/build-angular   17.0.6
@angular-devkit/core            17.0.6
@angular-devkit/schematics      17.0.6
@angular/cdk                    17.0.3
@angular/material               17.0.3
@schematics/angular             17.0.6
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.2

Warning: The current version of Node (21.4.0) is not supported by Angular.

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Dec 12, 2023

@SetoKaiba, I am not really understanding when this happen, does this happen during prerendering, ng serve or when running the production server?

@SetoKaiba
Copy link
Author

SetoKaiba commented Dec 12, 2023

@SetoKaiba, I am not really understanding when this happen, does this happen during prerendering, ng serve or when running the production server?

I'm running with ng serve. It's happening during prerendering. It's in the SSR side, not the client side. @alan-agius4

@alan-agius4 alan-agius4 self-assigned this Dec 13, 2023
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Dec 13, 2023
…erver resolvedUrls

With vite `header.host` is undefined when SSL is enabled. This resulted in an invalid URL to be constructed.

Closes angular#26652
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Dec 13, 2023
…erver resolvedUrls

With vite `header.host` is undefined when SSL is enabled. This resulted in an invalid URL to be constructed.

Closes angular#26652
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Dec 13, 2023
…erver resolvedUrls

With vite `header.host` is undefined when SSL is enabled. This resulted in an invalid URL to be constructed.

Closes angular#26652
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Dec 13, 2023
…erver resolvedUrls

With vite `header.host` is undefined when SSL is enabled. This resulted in an invalid URL to be constructed.

Closes angular#26652
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Dec 13, 2023
…erver resolvedUrls

With vite `header.host` is undefined when SSL is enabled. This resulted in an invalid URL to be constructed.

Closes angular#26652
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Dec 13, 2023
…erver resolvedUrls

With vite `header.host` is undefined when SSL is enabled. This resulted in an invalid URL to be constructed.

Closes angular#26652
alan-agius4 added a commit that referenced this issue Dec 13, 2023
…erver resolvedUrls

With vite `header.host` is undefined when SSL is enabled. This resulted in an invalid URL to be constructed.

Closes #26652
alan-agius4 added a commit that referenced this issue Dec 13, 2023
…erver resolvedUrls

With vite `header.host` is undefined when SSL is enabled. This resulted in an invalid URL to be constructed.

Closes #26652

(cherry picked from commit a5d4735)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants