79247506

Date: 2024-12-03 12:02:23
Score: 0.5
Natty:
Report link

Redirect to web app to another page

Utilizing XFrameOptionsMode as discussed here worked for the situation on your code. I modified your given code.gs and got it to redirect to another page

Modified Code

// Function to handle web app requests
function doGet(e) {
  if (e.parameter.page) {
    var pageName = e.parameter.page.trim().toLowerCase();
    Logger.log(pageName);
    if (pageName !== "home") {
      //I modified this section to use setFrameOptionsMode
      var template = HtmlService.createTemplateFromFile(pageName);
      return template.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME)
        .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
    } else {
      return homePage();
    }
  } else {
    return homePage();
  }
}

function homePage() {
  var template = HtmlService.createTemplateFromFile("home");
  return template.evaluate();
}

Sample Output

Sample Output

References: XFrameOptionsMode

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: 4thAnd1