0

What I'm trying to do is to write some simple html document that would navigate to Conflunce but already logged in. The idea is to generate the Authorization header in this document and to navigate to my Confluence domain (different domain). The full code so far:

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
function myFunction() { 

   $.ajax({

       url: "https://myconfluenceurl",      
       type: "GET",
       crossDomain: true,
       dataType: 'jsonp',
       beforeSend: function(xhr) {
           xhr.setRequestHeader('Authorization', 'Basic djkffwffOnY5MA==');
       },
       success: function() {        
       }        
   }); 
}
</script>

</head>
<body onload="myFunction()">    
</body>
</html> 

And I'm getting an error:

Refused to execute script from [myconfluenceurl] because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Is it even possible what I'm trying to do? Or maybe I should try to do it different way..

I'm completely new to JavaScript so any help would be greatly appreciated.

Michal_Drwal
  • 526
  • 1
  • 9
  • 26
  • You can't set request headers when using JSONP. – Quentin Dec 06 '18 at 16:49
  • `crossDomain: true` is useless unless you are making a same origin request which will be redirected to a different origin. – Quentin Dec 06 '18 at 16:49
  • Without these two I'm getting a 403 error. – Michal_Drwal Dec 06 '18 at 16:54
  • Speculation: The error message in the console of the developer tools tells you that the 403 error was for the preflight request and not the actual request. – Quentin Dec 06 '18 at 17:00
  • Maybe, because the JSESSIONID cookie is set in the Response Headers. But when I put a simple "alert("OK") in "success: function()..." nothing happens.. So no success. So any idea how I can navigate to my Confluence with those cookies from the response headers? – Michal_Drwal Dec 06 '18 at 17:06

0 Answers0