【问题标题】:WordPress.com API working locally but not on App EngineWordPress.com API 在本地工作,但不在 App Engine 上
【发布时间】:2018-12-11 10:38:13
【问题描述】:

通过请求模块调用了 Wordpress API。在本地运行我的服务器,调用正确返回。使用邮递员正确返回网址。

但是,当我将我的应用程序部署到 Google App Engine 时,响应返回未定义的请求调用中的响应。

app.get('/api/test', (req, res) => {
  console.log("testing"); 
  // res.send({ express: 'Hello From testing' });
request('https://public-api.wordpress.com/rest/v1/sites/testblog.wordpress.com/posts', { json: true }, (err, response, body) => {
  console.log(response.statusCode)
  console.log(body); 
if (err) { return console.log(err); }
  console.log(body);
  res.send({ express: body.ID })
});
});

【问题讨论】:

    标签: node.js http google-app-engine request wordpress-rest-api


    【解决方案1】:

    当 App Engine 发出出站 HTTPS 请求(获取 URL)时,它会检查所请求 URL 的证书。如果由于任何原因证书无效,App Engine 将拒绝该请求。根据文档,disable host certificate validationverify_peer 的值设置为false

    您还应该阅读有关用于获取 URL 的 limits and quotas

    【讨论】:

      猜你喜欢
      • 2018-03-26
      • 1970-01-01
      • 2014-09-12
      • 2018-06-11
      • 1970-01-01
      • 1970-01-01
      • 2021-08-17
      • 2017-08-01
      • 2021-07-22
      相关资源
      最近更新 更多