0

Using VS code angular 14

Project was updated from angular 8

ng build and ng serve works fine.

But http://localhost:4200/ give this error: Failed to load resource: the server responded with a status of 404 (Not Found) :4200//assets/config.json:1

And I stuck here.

enter image description here

enter image description here

Marc
  • 9
  • 2
  • 1
    Hi, maybe because your assets url have two // ? if you enter in your browser http://localhost:4200/assets/config.json it shows something? – Ricardo Machado Jul 28 '22 at 20:24
  • was the code throwing this error prior to the angular upgrade ? what changes (roughly) do you remember making after the most recent commit that was not throwing this error ? – CCBet Jul 28 '22 at 22:16
  • you are right, removing one backslash reach the file, but why is there 2 backslash, can't find anywhere in the project files. I had baseUrl: 'http://localhost:4200/', in file protractor.conf.js, I removed the last backslash. I rebuild and but still the UI is looking for :4200//assets/config.json – Marc Jul 28 '22 at 22:18
  • The code has not change since angular was upgraded. – Marc Jul 28 '22 at 22:21
  • In the file configuration.service.ts there is this – Marc Jul 28 '22 at 22:39
  • private get configurationUrl(): string { const path = (environment.configurationPath.startsWith('/') ? '' : '/') + environment.configurationPath; const baseUrl = this.window.document.baseURI; return `${baseUrl}${path}`; } – Marc Jul 28 '22 at 22:39
  • I changed the first line because it is adding a backslash for I don’t know what reason. private get configurationUrl(): string { const path = environment.configurationPath; const baseUrl = this.window.document.baseURI; return `${baseUrl}${path}`; } And this solve the issue. So thank you all for your help, it made me think to look for this double backslash. – Marc Jul 28 '22 at 22:39

1 Answers1

0

In the file configuration.service.ts there is this

private get configurationUrl(): string { 
const path = (environment.configurationPath.startsWith('/') ? '' : '/') + environment.configurationPath; const baseUrl = this.window.document.baseURI; return ${baseUrl}${path}; 
}

I changed the first line because it is adding a backslash for I don’t know what reason.

private get configurationUrl(): string { 
const path = environment.configurationPath; const baseUrl = this.window.document.baseURI; return ${baseUrl}${path}; 
} 

And this solve the issue. So thank you all for your help, it made me think to look for this double backslash

Santosh Aryal
  • 1,276
  • 1
  • 18
  • 41
Marc
  • 9
  • 2