I am currently trying to build a web app with google apps script, and I have implemented a login function. The login happens as it should, but I then try to redirect the user to the dashboard of my web app. The current code for the dashboard is the basic code for a new HTML file within apps script with a h1 title, so there are no issues with it.
In my login.html file, this is how it should redirect the user to the dashboard page:
function onLoginSuccess(sessionId) {
if (sessionId) {
console.log('Success')
console.log(sessionId)
window.location.href = "dashboard?sessionId=" + sessionId;
console.log('Success')
} else {
alert("Invalid email or password. Please try again.");
}
}
I have tried an url with "dashboard.html?sessionId=" +sessionId and I get the following error in the F12 console: Failed to load resource: the server responded with a status of 500 ()
I then tried an url without the html "dashboard?sessionId=" +sessionId and I now get the following error: Refused to display 'https://developers.google.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
I then tried adding .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL); with my return HtmlService line, but I still get the error.
With both URLs, both success and the session ID get called into the console.
Is there a way to fix the issue? Maybe another way to redirect the user, or just a way to fix the error?