[英]how can I put api key in the back when i call api from angular
In my current Agular app im sending a request to back end and i need to add api key as below:在我当前的 Agular 应用程序中,我向后端发送请求,我需要添加 api 密钥,如下所示:
let header = new HttpHeaders()
header = header.append("api-key","jkhjkh")
this.http.get(`https://api/${"EUR"}+${"SEK"}`,{headers:header}).subscribe(s=>{....
the problem is im exposing the api key to the user,its shown on the browser which is not secure,i was seraching on the google and found they say you have to put api key on the backend,if i do that how can i call then?please help me with an example or suggestion问题是我将 api 密钥暴露给用户,它显示在浏览器上不安全,我在谷歌上搜索,发现他们说你必须把 api 密钥放在后端,如果我这样做我怎么打电话那么?请帮我举个例子或建议
You need to keep the API-key away from the Angular frontend.您需要将 API 密钥远离 Angular 前端。 If you have an dotnet core backend, create a controller there that wraps your call to the API (with for example HttpClient ) and returns the response.
如果您有一个 dotnet 核心后端,请在此处创建一个 controller 来包装您对 API 的调用(例如HttpClient )并返回响应。
Angular <-> backend <-> API
key
Instead of代替
Angular <-> API
key
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.