I have an email verification route coming from nodejs. And I would like to display a page from my reactjs showing email verified. Both the nodejs and reactjs are on different ports. When the user clicks the verification link sent to their email, the verified page in react should be loaded. How best can this be achieved?
CodePudding user response:
React app is running on a different port just for the development process, after you'll be done developing you'll build the app and get static files to put on your node server to serve, so currently put in the mail the react link (with port 3000) and afterward just remember to change it to the port
CodePudding user response:
Just make a request to your backend from the React app. In the verification email, you can provide user with a query token: http://frontendlink.com/auth/email/verify?token=12345
. In useEffect
make a request to http://backendlink.com/api/v1/auth/email/verify?token=12345
, if the request succeeds: render a success component, if it fails: render an error component.
CodePudding user response:
You need pass a parameter from backend to react app. This parameter can be rendered in html body or url parameter something like a query string. When your react app loads, it must look if this parameter exists. If is found, then you navigate in you react app to the page you want to show.