On login, redirect the user back to where they were

Consider a web app having 2 pages: /home and /form .
There is also a login page /login .

Both pages require the user to be logged in. To achieve this, both these pages have the “Content Page Properties” -> “Server Side Data” -> “Server Connect” field selected to “/user” server action. The /user server action has a “Security Restrict” action.

Assume that the user went to one of the pages /form or /home directly, without being logged in.

The “Security Restrict” on the /user API redirects the user to /login .

When the user logs in, on the success of the login action, how do I take the user back to the page where they came from?

If the user had reached the /login page by being redirected from /home, then after login, I want the user to be taken back to /home.

This is usually achieved by attaching a “return_to” URL parameter to the /login page when the “Security Restrict” redirects the user. On successful login, the login page can read the “return_to” GET param and redirect there.

But I am unable to figure out how to send the “return_to” param to the /user API . Could someone help me achieve the above objective?

Community Page
Last updated: