I am developing an Angular application, whose purpose is to request a public API and render information in a convenient way with some graphics for our teams. In order to be able to access to this first API, I need to authenticate and get a bearer token through another one. I get the famous error about CORS as I try to authenticate to the second API:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
The request works fine if I use cURL, which seems totally normal, because CORS error comes from the browser.
The problem is I am not developing this API (for authentication) so I cannot set headers to allow cross-origin requests, and of course I don't want to use the proxy solution for Angular, which only works for dev environment.
So would it be possible to make use of cURL (I mean the real command line tool) through an Angular app, by clicking on a button ? Maybe is there any npm package which makes the host use curl ?
I did not find any solution about this.
I would like to:
- click on a button on the web app which executes a curl request on the host machine
- after curl is done, get the body response and save it in Angular
- parse the response, get the bearer token and use it as header for the next requests
Thank you in advance for helping.
Terry