如何从"doPost"获取原始URL.在Google Apps脚本上请求 [英] How to get the origin URL from a "doPost" request on google apps script

查看:61
本文介绍了如何从"doPost"获取原始URL.在Google Apps脚本上请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试确定对Google Apps脚本doPost()内容服务发出的POST请求的来源;

I've been trying to identify the origin of a POST request made to a Google Apps Script doPost() content service;

function doPost(request) {
   // Something like this:
   var originURL = request.headers.URL; // http://myurl.com

}

自从我将其发布(作为网络应用程序部署")以来,发布给所有人,甚至是匿名用户", 它具有以下标头:

Since I have published it ("Deploy as web app"), to 'Anyone, even anonymous', it has the following header:

access-control-allow-origin: *

所以我想在我的代码中控制它的访问.

So I want to control it's access in my code.

有可能吗?

推荐答案

我们不能在其他应用中使用直接发布方法,但可以使用URL参数传递尝试以下内容. 发布脚本确保您已更新版本并复制/exec链接. 您可以传递 https://../../exec?= para1 = 1012D .

We can not use direct post method in other aplication but you can use URL parameters passing try following. Publishing script makes sure you have updated version and copy /exec link. you can pass URL parameters like https://script../../exec?=para1=1012D.

更多详细信息单击此处

这篇关于如何从"doPost"获取原始URL.在Google Apps脚本上请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆