我在结合使用Node和BigCommerce方面没有很多经验,这确实是我的第一次尝试。我在Amazon的AWS EB上部署了NodeJS,当我尝试在BigCommerce上安装我的应用程序草案时,它卡在了安装程序中,并且进度指示器无限期保持。

我正在使用BigCommerce的文档中提到的npm包node-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>" }


我不太确定如何解决这个问题,关于节点和BC一起使用的文档也很少。我应该如何进行?

最佳答案

弄清楚了。有几件事,我完全忘记了在节点服务器上设置HTTPS,但是在完成设置之后,加载进度覆盖最终消失了。另一个缺少的链接是我在请求标头中使用的https://github.com/getconversio/node-bigcommerce包,它们使用的是Applications / json,但在这些之后应为“ Content-Type:application / x-www-form-urlencoded”夫妻改变了一切正常。

关于node.js - BigCommerce和NodeJS应用-身份验证,加载,卸载过程,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49060678/

10-11 01:00