slycat-server-rootΒΆ
Like any web service, the Slycat server could be deployed behind a reverse proxy, altering the URLs used by a client to access the REST API. For example, if an organization deployed an instance of Slycat at http://example.com/services/slycat, clients would retrieve the list of available projects at /services/slycat/projects instead of the usual /projects.
To facilitate this, the slycat-server-root AMD module returns a single constant string - the server root - which must be prepended to all URLs used by clients. For example, clients should never use hard-coded URLs:
jquery.ajax("/projects"); // NEVER DO THIS
Instead, the server root must be imported into the current namespace:
require(["slycat-server-root"], function(server_root)
{
// Use the server_root string here
});
And used to construct URLs dynamically at runtime:
jquery.ajax(server_root + "projects");
Note that clients should rarely need to construct URLs in the first place - instead, they should use the slycat-web-client module, which provides simplified access to the REST API and uses the server root for you.