5

I've just deployed my angular app to azure by running an ng build --prod and pushing it to git but I get a 404 error saying that it cannot find my json file I have in the assets folder.

I've also tried running ng build --prod --base-href "./" but I'm till getting the same error.

I'm currently trying to get the files in an api service like this:

return this.http.get('../assets/exercises.json')

but when I run the website on azure I get a 404 error Failed to load resource: the server responded with a status of 404 (Not Found)

Mike
  • 374
  • 1
  • 8
  • 22

1 Answers1

9

You need to add your own web.config.Its in the documentation of Angular: https://angular.io/guide/deployment

<staticContent><mimeMap fileExtension=".json" mimeType="application/json" /></staticContent>
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • 2
    https://stackoverflow.com/questions/46143147/not-running-angular-4-applicationon-from-azure-properly – Sajeetharan May 20 '19 at 03:05
  • 1
    Should I be adding this file just to my source folder and running ng build --prod or should I be putting it in the dist folder after the build? – Mike May 20 '19 at 03:17
  • The file should be added to your source folder, then ensure that you include it as an asset to be delivered within your application, via the angular.json or angular-cli.json file. – BluJ IT Mar 29 '21 at 17:26