Rewrite URL's from the JavaScript side to make them work relative to the
current page.

This isn't an ideal fix, but works reasonably well. I don't like the
magic that it adds, but I can't think of a better approach for now.