解决方法如下:
import { Auth } from 'aws-amplify';
Auth.signUp({
username: 'username',
password: 'password',
attributes: {
email: 'email@example.com'
}
})
.then(data => console.log(data))
.catch(err => console.log(err));
上述代码将在后端调用Cognito的注册API,而不会将注册页面公开展示给用户。
const AWS = require('aws-sdk');
const cognito = new AWS.CognitoIdentityServiceProvider();
const params = {
ClientId: 'your_client_id',
Username: 'username',
Password: 'password',
UserAttributes: [
{
Name: 'email',
Value: 'email@example.com'
}
]
};
cognito.signUp(params, function(err, data) {
if (err) {
console.log(err);
} else {
console.log(data);
}
});
上述代码将通过AWS SDK直接调用Cognito的注册API,而不会将注册页面公开展示给用户。
无论你选择哪种方法,都可以确保AWS Cognito注册页面不对外公开展示。