[SOLVED] Assets http get 404 only on devices


Out of nowhere or after having refreshed all my libs (still use Angular v5) I get the following error on devices (both iOS and Android) while trying to load assets

{“headers”:{“normalizedNames”:{},“lazyUpdate”:null},“status”:404,“statusText”:“Not Found”,“url”:“http://localhost:8080/assets/nothing.json",“ok”:false,“name”:“HttpErrorResponse”,“message”:"Http failure response for http://localhost:8080/assets/something.json: 404 Not Found”,“error”:null}

the code

                .subscribe((res: any) => {

My app is productive since a while, pushed many updates in store etc. code is the same and with ionic serve I can’t reproduce the problem

Double checked, assets files are correctly copied in the platform (which I didn’t removed and added, still the same as my successful delivery in both App store and Google Play)

Any idea where I should began to search the problem?



ok I found the root of the problem: in order to remove the hashbang # in the urls for my PWA I have set locationStrategy to 'path' in app.modules.ts

 IonicModule.forRoot(MyApp, {
   locationStrategy: 'path'

which actually block or break, as you want, all http.get to the local assets on both devices iOS and Android

removing the strategy fix the issue. I guess this gonna be one of a few things which will be different on PWA or Cordova…looking forward to v4 router to solve that :wink:


I think i got this problem right now. but did not understan path… it this the path to the assets?

 IonicModule.forRoot(MyApp, {
   locationStrategy: 'path'

My path is :
see picture.

What exactly do i write, The app-name it that the name i have in my XML.config?

I am in Home folder and what my XML file i have in Assets/xml…


no. that’s the url strategy, using path there means no hashbang in the urls


Ok so this is not my solution.

I am trying to read or get the XML file from my assets/xml/text.xml file…
But getting 404 error…

My XML File is located in this folder. And i can not get the data getting Error 404.
curlink_gv = '/assets/XML/myxmlfile.xml';

In Ionic 3 it works with the plugin

import { HttpClient } from '@angular/common/http';
import { HttpHeaders } from '@angular/common/http';

    loadXML(curYear_gv, curMonth_gv, curDay_gv, curCity_gv, curlink_gv)
        headers: new HttpHeaders()
        .set('Content-Type', 'text/xml')
        .append('Access-Control-Allow-Methods', 'GET')
        .append('Access-Control-Allow-Origin', '*')
        .append('Access-Control-Allow-Headers', "Access-Control-Allow-Headers, Access-Control-Allow-Origin, Access-Control-Request-Method"),
         this.parseXML(data, curYear_gv, curMonth_gv, curDay_gv)
            this.xmlItems = data;

But in Ionic 4 i only getting Error 404 ? As i sent you before the image you see my path…
My file is in assets and i calling from home.ts file. to ge the xml file to read.

I dont understand why they have change this?

Do oyu understand me?

I hope you can bare with me, and hope you can help …


No idea sorry, you should probably open a separate post for your question