无法向自己发出POST请求

时间:2020-07-06 23:12:20

标签: javascript google-apps-script

我正试图让我的Apps Script拥有数天的历史,以便将POST数据发送到自身。但是,提交表单后,出现SAMEORIGIN错误。奇怪的是,我正在另一个月的GAS Web应用程序上做同样的事情,没有问题...

<form action="<?= ScriptApp.getService().getUrl() ?>" method="post" id="loginForm">
<div class="input"><span class="label">Password:</span> <input type="password" name="password" id="password" required="required"></div>
<div class="input"><input type="submit" value="Log In"></div>
</form>

相同的表单在我的另一个Web应用程序上,是几个月前创建的,并且工作正常。

1 个答案:

答案 0 :(得分:1)

发现我的错误。这需要放在HTML头中:

<base target="_top">

这样,它会使用请求重新加载整个页面,而不仅仅是iframe沙箱。