BigCommerce和NodeJS应用程序 - 验证,加载,卸载过程

问题描述 投票:1回答:1

我在使用节点和BigCommerce方面没有太多经验,这是我第一次尝试。我在亚马逊的AWS EB上部署了一个NodeJS,当我尝试在BigCommerce上安装我的草案应用程序时,它在安装中陷入困境,进度指示器无限期地停留。

我正在使用BigCommerce的文档中提到的npm包节点 - 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
});

和我用于auth,加载,卸载的代码:

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的文档。我该怎么办?

node.js bigcommerce
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.