Creating a login; Protecting Chat-Ui route

I have created a login page, and connected it with my hugging face chat UI.
Upon entering the credentials, it checks the username, password and if the credentials are correct, it takes you to the chat UI.
Now the problem is, I can open the chat UI from the login page which is good.
But I only want it to open from the login page.
You can still access the chat UI directly.
I am thinking to use JWT authentication.
After the user validation, it already generates a JWT token. I have protected my backend routes (I.e., where my express.js server is exposed.) But I am having trouble doing the same for the chat UI.