Getting started but with HTTPS on Ubuntu

Highlighted
New Member
4 0 0

Hi Guys

 

I am just getting started with the app development. I am trying to follow the following tutorial:

 

https://developers.shopify.com/tutorials/build-a-shopify-app-with-node-and-react/embed-your-app-in-s...

 

With on major diff. I am using a Ubuntu server that is online. I therefore need to use HTTPS

const httpsOptions = {
  key: readFileSync('./ssl/privkey.pem'),
  cert: readFileSync('./ssl/fullchain.pem')
};


app.prepare().then(() => {
    const server = new Koa();
    server.use(session(server));
    server.keys = [SHOPIFY_API_SECRET_KEY];
    
    server.use(
        createShopifyAuth({
            apiKey: SHOPIFY_API_KEY,
            secret: SHOPIFY_API_SECRET_KEY,
            scopes: ['read_products'],
            afterAuth(ctx) {
                const { shop, accessToken } = ctx.session;
                
                ctx.redirect('/');
            },
        }),
    );
    server.use(verifyRequest());
    server.use(async (ctx) => {
        await handle(ctx.req, ctx.res);
        ctx.respond = false;
        ctx.res.statusCode = 200;
        return
    });
    const serverCallback = server.callback();
    
    createServer(httpsOptions, serverCallback).listen(port, err => {
        if (err) throw err;
        console.log(`> Ready on https://i-watch-dog.com:${port}`);
    })
    
//    server.listen(port, () => {
//        console.log(`> Ready on https://i-watch-dog.com:${port}`);
//    });
});
Internal Server Error

I get this error on the browser

 

and this one on the server:

TypeError: Key must be a buffer
      at new Hmac (crypto.js:117:16)
      at Object.createHmac (crypto.js:643:10)
      at Object.validateHmac [as default] (/home/watchdog/shopify/sample-embedded-app/node_modules/@shopify/koa-shopify-auth/dist/src/auth/validate-hmac.js:17:10)
      at /home/watchdog/shopify/sample-embedded-app/node_modules/@shopify/koa-shopify-auth/dist/src/auth/create-oauth-callback.js:24:52
      at step (/home/watchdog/shopify/sample-embedded-app/node_modules/tslib/tslib.js:136:27)
      at Object.next (/home/watchdog/shopify/sample-embedded-app/node_modules/tslib/tslib.js:117:57)
      at /home/watchdog/shopify/sample-embedded-app/node_modules/tslib/tslib.js:110:75
      at new Promise (<anonymous>)
      at Object.__awaiter (/home/watchdog/shopify/sample-embedded-app/node_modules/tslib/tslib.js:106:16)
      at oAuthCallback (/home/watchdog/shopify/sample-embedded-app/node_modules/@shopify/koa-shopify-auth/dist/src/auth/create-oauth-callback.js:9:24)
      at /home/watchdog/shopify/sample-embedded-app/node_modules/@shopify/koa-shopify-auth/dist/src/auth/index.js:58:46
      at step (/home/watchdog/shopify/sample-embedded-app/node_modules/tslib/tslib.js:136:27)
      at Object.next (/home/watchdog/shopify/sample-embedded-app/node_modules/tslib/tslib.js:117:57)
      at /home/watchdog/shopify/sample-embedded-app/node_modules/tslib/tslib.js:110:75
      at new Promise (<anonymous>)
      at Object.__awaiter (/home/watchdog/shopify/sample-embedded-app/node_modules/tslib/tslib.js:106:16)

 can someone tell me where I went wrong or if there is a better way to do this?

 

Thanks
Hannes

0 Likes
Highlighted
Shopify Partner
112 23 27

Hi Starhopper

 

Judging by the error message it looks like your environment variables are not set, specially the SHOPIFY_API_KEY and SHOPIFY_API_SECRET_KEY.

 

Check your .env file to see if everything looks ok. Another way to test this is to hardcode those values just to check if that's really the issue.

 

Let me know how that goes.

 

- Yes, we build Shopify Apps. Hit me with your idea: https://vellir.tech
- Let customers preview your products and easily add them to cart with Peek Mode
- Add free, good looking social share icons with built-in analytics to your store with Share Lab
- Manage your new arrivals with Newr
0 Likes
Highlighted
New Member
4 0 0

Hi 

 

 

 

 

[ ready ] compiled successfully
[ wait ]  compiling ...
> Ready on https://i-watch-dog.com:3000
[ ready ] compiled successfully
[ event ] build page: /next/dist/pages/_error
[ wait ]  compiling ...
[ ready ] compiled successfully
[ event ] build page: /
[ wait ]  compiling ...
[ ready ] compiled successfully
[ event ] disposing inactive page(s): /next/dist/pages/_error, /

 

 

 

0 Likes
Highlighted
Shopify Partner
112 23 27

You probably have some chrome extension causing this issue. Try disabling your extensions or use another browser

- Yes, we build Shopify Apps. Hit me with your idea: https://vellir.tech
- Let customers preview your products and easily add them to cart with Peek Mode
- Add free, good looking social share icons with built-in analytics to your store with Share Lab
- Manage your new arrivals with Newr
0 Likes