GET and POST sometimes fail sometimes don't

Hello,

my code works some parts of the day - sometimes not. I literally have pictures of it working then I come back and it doesn’t work.

I’m trying to send POST and GET requests to external sites. This is how I do it:

app.get("/amazon/", async (req, response) => {
  await axiosGet(
    `https://completion.amazon.com/search/complete?search-alias=aps&client=amazon-search-ui&mkt=1&q=/${req.query.query}`
  ).then((res) => {
    response.send(res.data);
  });
});

– code that goes to this route:

this.http.get(`http://localhost:8080/amazon/?query=${this.query}`)...

I’m using Angular and Express. So, I’m not sure what I’m doing wrong, I assume it’s something with ports… Sometimes it works - sometimes I get this:
(Reason: CORS request did not succeed). Status code: (null).

Site: https://shirt-helper.netlify.app/
Github: GitHub - ivan-pejic/shirt-helper-heroku

I’m not sure why you’re using Express for this. Can’t you call that Amazon API directly? It doesn’t appear that you’re using any keys or something that need to be hidden.

Well, when calling directly it always complains about CORS headers and stuff. I also need to make some http calls and I get a mixed content warning.

I figured out when it works - when I start the same node server locally. I thought my call to localhost would work the same when deployed, guess not. How do I make the correct request to communicate with Express?

When using Express on Netlify, you need to write a Netlify Function: