Redirect to https - error, reload to try again

I have a Debian server instaled with Docker and NGINX as reverse proxy.
If I go the https://domain.com i get the UI fine. No problem.
But if I try to reach the UI with http://domain.com, which should redirect to https, it shows an error banner and a “Reload to try again or log out”. If i reload the page it redirects fine.

In Chrome dev tools i can see this error in the Console.

XMLHttpRequest cannot load https://rancher.linuxnet.co/v1/token. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://rancher.linuxnet.co' is therefore not allowed access.

Why is this happening?

My NGINX conf file is as in the Docs. http://docs.rancher.com/rancher/installing-rancher/installing-server/basic-ssl-config/

It works now… No clue why ?!