在一起使用node和BigCommerce方面,我没有太多经验,这真的是我第一次尝试。我在亚马逊的AWS EB上部署了一个NodeJS,当我试图在BigCommerce上安装我的草稿应用程序时,它被安装卡住了,进度指示器无限期地停留。
我正在使用一个npm包节点-BigCommerce,它在BigCommerce的文档中提到:https://github.com/getconversio/node-bigcommerce/
目前,我的配置如下:
const bigCommerce = new BigCommerce({
logLevel: "info",
clientId: "my id",
secret: "my secret",
callback: "hostname",
responseType: "json",
apiVersion: "v3" // Default is v2
});
我用来验证、加载、卸载的代码:
router.get("/auth", (req, res, next) => {
bigCommerce
.authorize(req.query)
.then(data => res.render("auth", { title: "Authorized!", data: data }))
.catch(next);
});
router.get("/load", (req, res, next) => {
try {
const data = bigCommerce.verify(req.query["signed_payload"]);
res.render("load", { title: "Welcome!", data: data });
} catch (err) {
next(err);
}
});
router.get("/uninstall", (req, res, next) => {
try {
const data = bigCommerce.verify(req.query["signed_payload"]);
res.render("uninstall", { title: "Uninstalled!", data: data });
} catch (err) {
next(err);
}
});
我也尝试过使用常规的app.get('/',cb),什么都没有。另外,我还看到auth在数据中返回了以下内容:
{ title: "Authorized!", data: "<html><body>You are being <a href="https://login.bigcommerce.com/login">redirected</a>.</body></html>" }
我不太确定如何实现这一点,也没有太多关于一起使用node和BC的文档。我该如何继续呢?
发布于 2018-03-03 04:08:25
我想通了。有几件事,我完全忘记了在节点服务器上设置HTTPS,但在设置之后,加载进度覆盖终于消失了。另一个缺失的环节是我正在使用的包https://github.com/getconversio/node-bigcommerce,在请求头中,它们使用的是applications/json,但在这两次更改之后,这应该是"Content-Type: application/x-www-form-urlencoded“。
https://stackoverflow.com/questions/49060678
复制相似问题