Fixed the referer header, wrong info was sent. Added origin header
and some checks in the server-side script.