Creating a redirect for new users

Hi,

So I would like to start off by saying I am very new to the world of software development and am trying to build my first react app. I have implemented the login and logout with Auth0. I have one problem though When a new user logs in I would like them to be redirected to ‘/join’ instead of ‘/home’.

I set up a rule to facilitate the above example, which is :

  
if (context.stats.loginsCount === 1){
    context.redirect = {
        url: "https://localhost:3000/join"
    };
}
    return callback(null, user, context);
} 

which returns me to the correct url + state. like this :

https://localhost:3000/join?state=g6Fo2SBXUEJQZzlESzBxVWZUbGNyYXlKc2pXYmVFM2dBMDVCU6N0aWTZIGtFSzdISFQ0cVk2Y1cwTnFsaTJrd29kTjd2S3MtN0M4o2NpZNkgSzBtb3dRR2FTY1RNNGdUaHUzaE5pWUZydjFtbEt6ZDA

but it sends me to a web error page with the following :

This site can’t provide a secure connection

localhost sent an invalid response.

ERR_SSL_PROTOCOL_ERROR

Also, I have this error in the console :

index.js:410 There was an error fetching the SSO data. This could simply mean that there was a problem with the network. But, if a “Origin” error has been logged before this warning, please add “https://abellinii.au.auth0.com” to the “Allowed Web Origins” list in the Auth0 dashboard: https://manage.auth0.com/#/applications/K0mowQGaScTM4gThu3hNiYFrv1mlKzd0/settings

I can’t for the life of me seem to find the answer to fix this. I have searched far and wide but to no avail. I know that it is most probably a simple error. Could somebody please point me in the right direction?

Thanks in advance!!!

Hi everyone,

I still have not solved this. Could anyone help me please?

Hi @abellinii,

Welcome to the Community, and so sorry for the delayed response!

Have you in fact had an origin error and added your tenant to the allowed web origins in the dashboard? Would you also DM me your tenant name and application name from the dashboard?

Thanks,
Dan

@abellinii Everything looks okay in your tenant. Is this error because you are making an https request to localhost and there is no ssl certificate for localhost? Can you try setting your redirect url in the rule to http://localhost:3000/join

Let me know!

Thanks,
Dan

Thank you Dan. A silly mistake but that seems to be the problem. I still have an issue parsing the url and sending back but I should be able to fix that.

1 Like

Glad to hear it was solved!

Good luck,
Dan

So I have it working now and on sign in it will redirect from http://localhost:3000 to http://localhost:3000/join. Then Auth0 redirects to http://localhost:3000/join?state=THE_ORIGINAL_STATE . I then parse that url and redirect to http://localhost:3000continue?state=THE_ORIGINAL_STATE but It does not log in. I know it is most probably something simple. Any ideas @dan.woda ?

Ok, I fixed that problem. It actually needs to redirect to my domain http://abellinii.au.auth0.com/continue?state=THE_ORIGINAL_STATE instead of http://localhost:3000/join?state=THE_ORIGINAL_STATE. Now after that it redirects to the lock authorization page but once I click authorize it will bring me to the home page instead of the intended redirect “/join” I had originally set up the redirect rule for to sent it to.

@abellinii,

This might have something to do with the authorization app dialogue box. Try disabling it and see what happens.

Thanks,
Dan