WordPress.com API 在本地工作但不在 App Engine 上工作
WordPress.com API working locally but not on App Engine
通过请求模块调用了 Wordpress API。 运行 我的服务器本地调用 returns 正确。正确使用 postman url returns。
然而,当我将我的应用程序部署到 Google App Engine 时,请求调用中的响应未定义响应 returns。
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 })
});
});
当 App Engine 发出出站 HTTPS 请求(获取 URL)时,它会检查请求的证书 url。如果出于任何原因证书无效,App Engine 会拒绝该请求。根据文档,要 disable host certificate validation 将 verify_peer
的值设置为 false
。
您还应该阅读 limits and quotas 以获取 URL。
通过请求模块调用了 Wordpress API。 运行 我的服务器本地调用 returns 正确。正确使用 postman url returns。
然而,当我将我的应用程序部署到 Google App Engine 时,请求调用中的响应未定义响应 returns。
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 })
});
});
当 App Engine 发出出站 HTTPS 请求(获取 URL)时,它会检查请求的证书 url。如果出于任何原因证书无效,App Engine 会拒绝该请求。根据文档,要 disable host certificate validation 将 verify_peer
的值设置为 false
。
您还应该阅读 limits and quotas 以获取 URL。