HttpClient.get retrieving index.html instead of an asset file

Discussão em 'Angular' iniciado por Matthew Coatney, Dezembro 25, 2024.

  1. When I run the code below locally it works fine. When it is pushed to server (AWS Amplify) it fails to work correctly.

    In the console there is an error:


    ERROR Error: Invalid HTML: could not find <table>
    ​

    Code:

    this.http
    .get("./assets/data/test.txt", { responseType: "text" })
    .subscribe((data) => {
    console.log(data);
    });


    When run locally the output is whatever text is inside the file. When run from the server the output is the HTML of the Angular app.

    I tried different file names and response types before discovering that the HTML was being returned.

    Continue reading...

Compartilhe esta Página