I managed to get to use the server variable script_name ($_SERVER['SCRIPT_NAME']) in my workflow but that gets the path of the workflow, and I need the path of the page thayt calls the server action.
You can view the "web server logs" output when a page is requested, when "debug" is on, to see all of the available Server variables available. It looks like the below picture. Just put $_SERVER in front of any of these variables like you did with SCRIPT_NAME.
When a script is called via AJAX, it executes in the context of the backend server. So $_SERVER in PHP does not directly provide the URL of the page where the AJAX request originated.
You can create a GET variable in the server action and on the front end add the current URL using the data returned from the browser component.
You'd be looking at something called server-side binding, you can search the forum, but make sure it's for PHP. That's how you inject server-side variables into a client-side web page.
I'd then create a variable on the front-end, and put the server-side binding expression inside the value attribute.