There are two distinct projects under consideration.
Authentication Project: is hosted at http://localhost:4200
.
This project contains a login page where users can input their credentials to sign in.
Upon successful login, the user will be redirected to another project called Application
.
Application Project: is hosted at http://localhost:8000
If the user has logged in successfully, they will arrive at the dashboard located at http://localhost:8000/dashboard
within this application project.
So far, everything seems to be functioning correctly.
In the event that a user attempts to access http://localhost:8000/dashboard
directly, I want them to be redirected to http://localhost:4200
for signing in.
Since access to this project http://localhost:8000/dashboard
is restricted without signing in. Auth guard measures have been implemented and are working properly.
What I require is if a user inputs the URL as http://localhost:8000/users
(note the URL contains users) directly, then they should be directed to the sign-in page. Upon successful sign-in, they should be redirected to the same URL from which they initially accessed.
Therefore, the scenario involves a user manually entering the URL as http://localhost:8000/users
, being met with the sign-in page due to not being logged in, and upon successful sign-in, being redirected to http://localhost:8000/
. However, I need to redirect them to http://localhost:8000/users
instead, as that was their original location.
How can I retrieve the URL from which the user came?
My applications are built using Angular 7.