How to get the visit source url to find out the visit is valid or invalid?

If my current streamlit web page url is: http://abc.com.cn:8501
not anyone can open this page directly.
in the design, the visitors must come from a specific url, such as http://def.com.cn
how to get the url of visit source url to find out the visit is valid or invalid?