Add support for /proxy URI and refactor session check.