I have this simple script to get a page and output it unchanged. However, the browser doesn't recognize the output as HTML and shows it as text.
function doGet(e) {
var url = e.queryString || "";
if (url != "") {
return getPage(url);
}
return "not found";
}
function test() {
return getPage("www.google.com");
}
function getPage(url) {
var options = {
headers : {'Cache-Control' : 'max-age=0'}
};
var response = UrlFetchApp.fetch(url, options);
var html = response.getContent();
return ContentService.createTextOutput(html).setMimeType(ContentService.MimeType.HTML);
}
What's wrong? How can I output the fetched page as HTML?