ofgodsandmythos
ofgodsandmythos

Reputation: 51

How can I get external API proxy for Angular 8 working correctly instead of defaulting to localhost

I am basically trying to run a dev Angular application so I can write and test services easier for our production NativeScript app.

It requires an external API and I have tried multiple ways to get around the CORS issue. Many references only state that I have to do the following:

{
  "/main-feed": {
  "target": "https://endpoint.org",
  "secure": true,
  "logLevel": "info",
  "changeOrigin": true
}

I have gotten this proxy to work with localhost but for an external api when I hit the final endpoint /main-feed/v1/items it gives me back an error that states:

GET http://localhost:4200/main-feed/v1/items 404 (Not Found)

I have tried /main-feed/ and /main-feed/*.

It would be really great if I could get this working but I understand if Angular is not built for this. I really wish it was easier for development to override CORS but I understand the risk.

Upvotes: 0

Views: 375

Answers (1)

BELLIL
BELLIL

Reputation: 765

What is the full URL of your back end point?

Did you try to set up a proxy config? If not please take a look at this link

PS: don't forget the port in your target

Upvotes: 1

Related Questions