Here's how to get the URL of current page (with parameters) in SSJS:
var url = Platform.Request.RequestURL();
Effectively, it's the equivalent of RequestParameter('PAGEURL')
in AMPscript.
However, this only provides the base url, without the query parameters. Hence if placed in a Cloud Page which is called: https://cloud.e.example.com/whatever?foo=bar&john=doe, I only receive https://cloud.e.example.com/whatever in each of these functions. Is there a way of receiving the complete URL with all request parameters?
Update:
This code is used in a code resource, which is called with a set of request parameters. One of which is a URL (which is sent as PageUrl request parameter), telling which page has called the code resource.
The odd behaviour is, that Platform.Request.RequestURL();
is returning the correct full URL with all request parameters, UNLESS one of these parameters contains a URL of it's own. In this case, only the URL in the parameter gets returned by Platform.Request.RequestURL();
. And yes, I did verify this is not related to a single variable in SSJS getting overwritten with the URL from that particular request parameter.
Any suggestions for an alternative solution?