当我向API URL提交发布请求时。每当我包含授权时,它都会失败。当我尝试使用API登录时。它工作正常。但后来。当我尝试让所有用户使用其Auth令牌时。它使请求失败。我正在使用HttpClient。 (@ angular / common / http)
const httpHeaders = new HttpHeaders({
'Access-Control-Allow-Credentials': 'true',
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + environment.authTokenKey });
const users = this.http.post<User[]>(API_USERS_URL, null, { headers: httpHeaders});
return users;