Hi,
I’ve connected a social connection with my clientID and Client Secret from google.
Im trying to redirect new users to a welcome page in order to collect more data about the user using auth0 Rules.
I configured the following rules:
function (user, context, callback) {
if (context.stats.loginsCount === 1) {
context.idToken.firstLogin = true;
context.redirect = {
url: "http://localhost:3000/welcome"
};
}
callback(null, user, context);
}
function(user, context, callback) {
if (context.protocol === "redirect-callback") {
// User was redirected to the /continue endpoint
const _ = require('lodash');
const RULE_NAME = 'Check for resumed login';
user.user_metadata = user.user_metadata || {};
user.user_metadata = Object.assign(user.user_metadata,
_.pick(context.request.body, ['role']));
console.log(`${RULE_NAME}: ${user.user_id}: Updating user profile`);
auth0.users.updateUserMetadata(user.user_id, user.user_metadata)
.then(() => callback(null, user, context))
.catch((err) => {
console.log(`${RULE_NAME} ERROR:`, err);
callback(err);
});
} else {
// User is logging in directly
return callback(null, user, context);
}
}
In /welcome
I extract the state from the redirect uri and POST to /continue
with the collected data
await fetch(redirectTo, {
method: “POST”,
cache: “no-cache”,
headers: {
“Content-Type”: “application/json”,
Origin: “http://localhost:3000”
},
body: JSON.stringify({ role })
});
I get cors error from auth0 even though http://localhost:3000 is regsitered in Allowed Web Origins
and Allowed Origins (CORS)
Can someone suggest a solution?