I have a simple react app, and I'm trying to redirect the user to a login page if they came directly without logging in.
App.js
useEffect(() => {
if (document.referrer === "") {
window.location.replace("../loginpage.php");
} else {
console.log("user came through login")
}
})
This works perfectly for Chrome and Edge.
The problem
When I refresh the pages, Mozilla directs me back to the Login page whereas Chrome and Edge stays on the same page.
For some reason document.referrer is not working as expected in Mozilla. Any help is appreciated. Thanks !