Does discourse has return_path or return_link I can leverage to redirect to previous link after log in complete?

Why does after logging in Discourse doesn’t return to this path?

https://discourse.test.com/login?return_path=%2Fsecure-uploads%2Foriginal%2F2X%2F0%2F0f72a30f024ed5e37791d404a1fc611e90606650.pdf

Essentially we want below scenario to work

User visits a file thats not open to public they see 404 and redirected to login after few seconds and after logging they should come back to file and download?

Do I need to do anything custom? I just added return_path at the end using javascript on component.

Please help me out!

TY

There is a cookie called ‘destination_url’ that adds the page before login (e.g. a topic), and uses the cookie, then removes it after login is successful.

thank you very much!