rewrite redirection to origin with cookie.
add document for improved origin handling.
cleanup document.