Cross domain API calls in web-component, multiple environments

Viewed 136

I have 2 questions:

1)

I'm working on a web component in Angular. In our project, we have multiple test environments + production. Assume there are multiple APIs on domains as follow:

https://domain.dev1.com/api/v1

https://domain.dev2.com/api/v1

https://domain.dev3.com/api/v1

https://domain.prod.com/api/v1

Web-component must be working across all environments. Important fact is, that web-component will be working on DIFFERENT domain than API. (lets say https://anotherdomain.com). How to configure it properly? I was thinking of 4 different environment.ts files with these urls. Sth like:

file: environment.dev1.ts

export class Environment {
   apiUrl: https://domain.dev1.com/api/v1
}

and use this variable in code. Is that proper solution?

2)

In this web-component I will be using another web component, that is configured to use API on the same domain (relative paths to API). Can i make somehow a proxy to use this API? (as I said before, my web-component is on different domain).

Hope I explained everything well.

0 Answers
Related