title: Mixed content jQuery ajax HTTPS request has been blocked on Laravel
body: <p>I think this question will be easy for someone and will be a face-palm situation for me.</p>
  
  <p>I have a Laravel 5.3 site, and various pages have ajax requests. Because I use the <a href="https://laravel.com/docs/5.3/csrf" rel="noreferrer"><code>csrf_field()</code></a> feature, they work fine.</p>
  
  <p>But there is one page where the ajax produces this error: </p>
  
  <pre><code>Mixed Content: The page at 'https://example.com/fb/reports' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://example.com/fb/json?levelType=&amp;id=&amp;aggLevel=ad&amp;start=&amp;end='. This request has been blocked; the content must be served over HTTPS.
  </code></pre>
  
  <p>My javascript looks like this:</p>
  
  <pre><code>    var relUrl = '/fb/json/';
      var payload = {
          levelType: levelType,
          id: id,
          aggLevel: aggLevel,
          start: start,
          end: end
      };
      console.log(relUrl);
      return $.ajax({
          type: 'GET',
          dataType: 'json',
          data: payload,
          url: relUrl,
          headers: {
              'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
          }            
      });
  </code></pre>
  
  <p>I've read <em>tons</em> of articles about this error. I've tried tons of suggested solutions, including changing the relative URL to the full https URL, or starting it with 2 slashes. </p>
  
  <p>I've even tried changing the way my Laravel routes work and am now using just querystring parameters.</p>
  
  <p>I've studied all of the articles below (and more).</p>
  
  <p>Also, since this one ajax query is in a password-protect part of the site (and the ajax queries that <em>work</em> are in a public/open part of the site), I figured maybe that was related to the problem. But then I used <code>SSH</code> to log into the production server and <code>vim</code> to temporarily remove the line that required any authentication, and the https error <em>still</em> happens.</p>
  
  <p>What steps can I take to debug further from here?  What logs can I 'tail' on my Cloudways server?</p>
  
  <p>Is there anything that Cloudflare might be interfering with (which I doubt, since other ajax queries work, all on https)?</p>
  
  <p>Thanks!</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/36008995/jquery-ajax-request-to-https-getting-served-to-http-with-laravel-and-select2">jQuery AJAX Request to HTTPS getting served to HTTP with Laravel and Select2</a></li>
  <li><a href="https://stackoverflow.com/questions/28134098/this-request-has-been-blocked-the-content-must-be-served-over-https?rq=1">This request has been blocked; the content must be served over HTTPS</a></li>
  <li><a href="https://stackoverflow.com/questions/34172075/mixed-content-issue-insecure-xmlhttprequest-endpoint">Mixed content issue - insecure XMLHttpRequest endpoint</a></li>
  <li><a href="https://stackoverflow.com/questions/31181846/xhr-response-blocked-by-chrome-because-of-mixed-content-issue-http-https?rq=1">XHR response blocked by Chrome, because of mixed content issue (http/https)</a></li>
  <li><a href="https://stackoverflow.com/questions/28277443/forcing-ajax-call-to-be-https-from-https-page">Forcing AJAX call to be HTTPS from HTTPS Page</a></li>
  <li><a href="https://stackoverflow.com/questions/28197528/mixedcontent-when-im-loading-https-page-through-ajax-but-browser-still-thinks">MixedContent when I&#39;m loading https page through ajax, but browser still thinks it&#39;s http</a></li>
  <li><a href="https://stackoverflow.com/questions/13556772/jquery-ajax-wont-make-https-requests">jQuery ajax won&#39;t make HTTPS requests</a></li>
  <li><a href="https://stackoverflow.com/questions/32153092/laravel-5-1-ajax-url-parameter-is-url">Laravel 5.1 ajax url parameter is url</a></li>
  </ul>