请注意,这在使用Functions Framework在本地进行测试时非常有效。
我刚刚部署了一个功能
Deploying function...
gcloud functions deploy quantumjs-api --runtime nodejs10 --trigger-http --project qunatumvue --region europe-west2
Deploying function (may take a while - up to 2 minutes)...done.
availableMemoryMb: 256
entryPoint: quantumjs-api
environmentVariables:
location: production
httpsTrigger:
url: https://europe-west2-qunatumvue.cloudfunctions.net/quantumjs-api
labels:
deployment-tool: cli-gcloud
name: projects/qunatumvue/locations/europe-west2/functions/quantumjs-api
runtime: nodejs10
编辑----感谢Doug Stevenson的ping指针
但是,向其中发布数据时,我没有得到任何回复,只是这个错误:
"Error: Network Error
at createError (webpack-internal:///./node_modules/axios/lib/core/createError.js:16:15)
at XMLHttpRequest.handleError (webpack-internal:///./node_modules/axios/lib/adapters/xhr.js:87:14)"
答案 0 :(得分:0)
您无法ping通URL。您ping主机名。您提供的URL中的主机名是“ europe-west2-qunatumvue.cloudfunctions.net”。当我ping通时,就可以了:
user@host 18:26 $ ping europe-west2-qunatumvue.cloudfunctions.net
PING www3.l.google.com (173.194.202.138) 56(84) bytes of data.
64 bytes from pf-in-f138.1e100.net (173.194.202.138): icmp_seq=1 ttl=42 time=29.3 ms
64 bytes from pf-in-f138.1e100.net (173.194.202.138): icmp_seq=2 ttl=42 time=29.3 ms
64 bytes from pf-in-f138.1e100.net (173.194.202.138): icmp_seq=3 ttl=42 time=29.3 ms
如果要检查URL是否有效,则应使用curl或某些HTTP库访问它。
答案 1 :(得分:0)
我发现了问题,我不得不将所有流量重定向到https,这就是我的域在cors策略文件中注视的内容