Closed lonag closed 2 months ago
Moon不直接支持https, HTTPS需要用代理,可以看下wiki
示例
--httpsGoogle登录令牌认证
local function GoogleTokenVerify(token, userId)
local url = string.format("https://oauth2.googleapis.com")
local response = httpc.get(url, {
path = string.format("/tokeninfo?id_token=%s", token),
proxy = "http://127.0.0.1:8443" -- 这里设置nginx http->https 正向代理
})
if response == nil or response.status_code ~= 200 or response.content == nil then
return 1
end
local jsonStr = json.decode(response.content)
if jsonStr == nil then
return 2
end
if jsonStr["sub"] == nil or jsonStr["sub"] ~= userId then
return 3
end
return 0
end
好吧
好吧
主要原因是带上 OpenSSL 编译,会增加编译复杂度,使用nginx更加简洁高效, 并且线上环境一般都会依赖nginx。开发环境一般在内网部署一个,可以项目组共用。
使用httpc.get访问https接口,看表现是会用http访问。