PREFERRED_URL_SCHEME doesn't seem to work in Jinja2 Flask Template
<p>I am implementing FB login on my webapp here <a href="https://www.glifft.com." rel="nofollow noreferrer">www.glifft.com</a> but I can't seem to get the redirect right. The redirect after logging in should be to <a href="https://www.glifft.com/myglifft" rel="nofollow noreferrer">https://www.glifft.com/myglifft</a>. I'm using the url_for() function in Flask in the Jinja2 template to generate this URL. But I can't seem to generate with the https in front. It always generates as http. </p>

<p>Here is my JavaScript: </p>

<pre><code>function getuserDetails(accessToken) {
   FB.api('/me',{ locale: 'en_US', fields: 'name, email' }, function(response) {
         $.ajax({
             url: "/register",
             type: "POST",
             data: {
                     name: response.name,
                     email: response.email,
                     login_provider : "Facebook",
                     access_token: accessToken
                 },

                 success: function(response) {
                     location.href = "{{ url_for('myglifft', _external=True) }}";
                     console.log(location.href)
                 },
                 error: function(response) {
                     alert("Please check your facebook privacy settings.");
                     console.log(response)
                 }
         });
     });
</code></pre>

<p>The location.href function keeps resolving to <a href="http://www.glifft.com" rel="nofollow noreferrer">http://www.glifft.com</a>. Even though in my config I have </p>

<pre><code>PREFERRED_URL_SCHEME = 'https'
</code></pre>

<p>The error I get in chrome is this: </p>

<p><a href="https://i.stack.imgur.com/mYOY3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mYOY3.png" alt="Chrome Console Error"></a></p>

<pre><code>Mixed Content: The page at 'https://www.glifft.com/login' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.glifft.com/myglifft'. This request has been blocked; the content must be served over HTTPS.
</code></pre>

<p>It seems like this should work. Why is the PREFERRED_URL_SCHEME flag not working????</p>