3

I am using static data from "assets" folder, by importing like this:

import programmeManagment from './../../../assets/mock-json/programme-management.json';

and using in service like:

return of(JSON.parse(JSON.stringify(programmeManagment)));

it works fine in local host. when i move the code to server, it shows the error as:

https:xxx.azurewebsites.net/assets/mock-json/programme-management.json 404 Not Found response shows as:

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

how to come up with this?

3gwebtrain
  • 14,640
  • 25
  • 121
  • 247
  • what happens when you paste `https:xxx.azurewebsites.net/assets/mock-json/programme-management.json` in browser did it download or open the file? – jitender Sep 26 '19 at 07:10
  • @jitender : `The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.` – 3gwebtrain Sep 26 '19 at 07:11
  • this may help http://microdesigncentre.com/hosting-angular-app-on-windows-azure-resource-you-are-looking-for-has-been-removed/ – jitender Sep 26 '19 at 07:15
  • @3gwebtrain Its looks like this `./../../../` part may be going into the wrong directory to seach file – Prashant Pimpale Sep 26 '19 at 07:16
  • @Prashant but it works fine with local host right? – 3gwebtrain Sep 26 '19 at 07:17
  • Yes, agreed! what is your baseurl while build/publish? or have you written any URL Rewrite rules? – Prashant Pimpale Sep 26 '19 at 07:19
  • One more SO post related to your question https://stackoverflow.com/questions/38054707/angular-2-azure-deploy-refresh-error-the-resource-you-are-looking-for-has-been – jitender Sep 26 '19 at 07:19
  • @Prashant:@base url in `index.html` -? `` – 3gwebtrain Sep 26 '19 at 07:20
  • @3gwebtrain Okay and what about second question? about Url rewrite role on server? – Prashant Pimpale Sep 26 '19 at 07:22
  • I don't write any url rewrite rules, it will be in tsconfig file right? there is nothing. config base url : `"baseUrl": "./",` – 3gwebtrain Sep 26 '19 at 07:23
  • 1
    @3gwebtrain Nope it has to be written on IIS/Azure server [check this or search](https://stackoverflow.com/questions/53940859/host-angular-7-in-azure-web-app-url-rewrite-problem) + [this](https://stackoverflow.com/questions/42786139/host-angular2-app-with-routing-in-azure) – Prashant Pimpale Sep 26 '19 at 07:26

3 Answers3

0

Try like this:

this.http.get('./../../../assets/mock-json/programme-management.json').subscribe( res => {
    console.log(res)
})
Adrita Sharma
  • 21,581
  • 10
  • 69
  • 79
0

Please check file programme-management.json is available in your hosted location.

If not there try changing special character from the file name.

instead of,

programme-management.json.

use this,

programmemanagement.json

rafi muhammad
  • 194
  • 2
  • 11
0

I suggested by prashath, got issue fixed. sharing for others to use it. taken the answer from here: Host Angular 7 in Azure web app URL rewrite problem

 "assets": [
      "src/assets",
      "src/favicon.ico",
      "src/web.config" <---- Removed this line
    ],
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
3gwebtrain
  • 14,640
  • 25
  • 121
  • 247