title: CORS issue using GET from Angular 6 to Google Apps Script
body: <p>I've created a very simple Script using Google Apps Script which reads a spreadsheet and return a JSON:</p>
  
  <pre><code>function doGet(e){
  
   // Change Spread Sheet url
   var ss = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1DLVP96405P7djwPAJpGRRgIOFCiJwnktr1Z4HFz9ooI/edit#gid=811553549");
  
  // Sheet Name, Chnage Sheet1 to Users in Spread Sheet. Or any other name as you wish
   var sheet = ss.getSheetByName("NumeroMortosConfrontos");
  
   return getConfrontos(sheet); 
  
  }
  
  function getConfrontos(sheet){
    var jo = {};
    var dataArray = [];
  
  // collecting data from 2nd Row , 1st column to last row and last column
    var rowCabecalho = sheet.getRange(18,1, 1, 6).getValues();
    var dataRowCabecalho = rowCabecalho[0];
    var cabecalho = [];
    cabecalho.push(dataRowCabecalho[0]);
    cabecalho.push(dataRowCabecalho[1]);
    cabecalho.push(dataRowCabecalho[2]);
    cabecalho.push(dataRowCabecalho[3]);
    cabecalho.push(dataRowCabecalho[4]);
    cabecalho.push(dataRowCabecalho[5]);  
  
    var rows = sheet.getRange(19,1, 14, 6).getValues();
  
    for(var i = 0, l= rows.length; i&lt;l ; i++){
      var dataRow = rows[i];
      var record = [];
      record.push(dataRow[0]);
      record.push(dataRow[1]);
      record.push(dataRow[2]);
      record.push(dataRow[3]);
      record.push(dataRow[4]);
      record.push(dataRow[5]);
  
      dataArray.push(record);   
    }  
  
    jo.cabecalho = cabecalho;
    jo.dados = dataArray;
  
    var result = JSON.stringify(jo);
  
    return ContentService.createTextOutput(result).setMimeType(ContentService.MimeType.JSON);
  
  }  
  </code></pre>
  
  <p>After publishing, I call the endpoint in my browser and works well as you can see in the link below:</p>
  
  <p><a href="https://script.google.com/macros/s/AKfycbxk616n8wjgGeHZIc3Hm66Kcv4ZtWKZJQnEKLsxZC9LpoDK8mQZ/exec" rel="nofollow noreferrer">https://script.google.com/macros/s/AKfycbxk616n8wjgGeHZIc3Hm66Kcv4ZtWKZJQnEKLsxZC9LpoDK8mQZ/exec</a></p>
  
  <p>I've tried to call this link using HTTP Get from an Angular application, but when I open it, I see the error: </p>
  
  <blockquote>
    <p>Failed to load resource: the server responded with a status of 405 ()
    :4200/#/estatistica/confrontos:1 Failed to load
    <a href="https://script.google.com/macros/s/AKfycbxk616n8wjgGeHZIc3Hm66Kcv4ZtWKZJQnEKLsxZC9LpoDK8mQZ/exec" rel="nofollow noreferrer">https://script.google.com/macros/s/AKfycbxk616n8wjgGeHZIc3Hm66Kcv4ZtWKZJQnEKLsxZC9LpoDK8mQZ/exec</a>:
    Response to preflight request doesn't pass access control check: No
    'Access-Control-Allow-Origin' header is present on the requested
    resource. Origin '<a href="http://localhost:4200" rel="nofollow noreferrer">http://localhost:4200</a>' is therefore not allowed
    access.</p>
  </blockquote>
  
  <p>I've been searching a lot of question and answers about it, but I really dont know what I have to do, what configuration I need to write and where (server side or client side). How could I solve this problem and receive the JSON in my front end application?</p>