ユーザー プロファイルを読み取ることができ、Angular 2 アプリケーションで Auth0 からユーザー メタ データを更新できます。このように
this.lock.getProfile(authResult.idToken, (error, profile) => {
if (error) {
// Handle error
alert(error);
return;
}
と
this.authHttp
.patch('https://' + myConfig.domain + '/api/v2/users/' + this.auth.userProfile.user_id, data, {headers: headers})
.map(response => response.json())
.subscribe(
response => {
this.auth.userProfile = response;
localStorage.setItem('profile', JSON.stringify(response));
this.router.navigate(['/profile']);
},
error => alert(error.json().message)
);
しかし、すべてのユーザーがエラーを取得しようとしている間-"Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 404."
これがコードです
var headers: any = {
"Content-Type": "application/json; charset=utf-8",
"cache-control": "no-cache"
};
this.authHttp
.get('https://' + myConfig.domain + '/api/v2/users/' + '?per_page=100&page=0&search_engine=v2', { headers: headers })
.map(response => response.json())
.subscribe(
response => {
console.log(response);
},
error => alert(error.json().message)
);
Web サイトでクライアント テストが正常に動作している場所
https://auth0.com/docs/api/management/v2#!/Users/get_users
何が問題なのかわかりません。
Access-Control-Allow-Origin のヘッダーにも同じ問題があります
var headers: any = {
"Content-Type": "application/json; charset=utf-8",
"cache-control": "no-cache",
"Access-Control-Allow-Origin": "*"
};