Reputation: 46
My Angular app hosted AWS Amplify is redirecting my HttpClient.get call to a CSV file in assets folder to the index.html file. The result is that the data I want to parse as CSV is actually the HTML from index.html
Please note that when running the code locally in development the correct csv file is retrieved and displayed.
I am aware of this resource: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa
</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|json|svg|woff|ttf|otf)$)([^.]+$)/>
CSV is not on the default list here. So I can't simply remove it to prevent the redirection.
What I want to do is allow the file in the assets folder to be loaded by Angular to be used in the frontend. As I mentioned previously it works locally. So it must have something to do with server.
The code is simple
this.http
.get("./assets/data/inventory.csv", { responseType: "text" })
.subscribe((data) => {
console.log(data);
});
I have also used arraybuffer responseType with no change. I have removed .csv extension from file with no change.
I get this error:
ERROR Error: Invalid HTML: could not find `<table>`
I think there must be a redirect in Amplify console or a different way of using HttpClient.get that I am not aware of or some amplify configuration I need to implement.
I will say I have used this code before in another project without this problem. So Im reusing code that worked before which is frustrating. This seems like it should be straight forward. So what am I missing?
Upvotes: 0
Views: 45