So I'm following https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react but ever since I ngrok'd it's too slow.Is there any way I can develop locally? I know Shopify is a hosted solution but ngrok makes it way slow for me. I'm from India & I think the servers are from US & it's so slow that it takes literally 5 mins & sometimes it doesn't even load properly at all.Here's my current server.js:```js require('isomorphic-fetch') const dotenv = require('dotenv') const Koa = require('koa') const next = require('next') const { default: createShopifyAuth } = require('@shopify/koa-shopify-auth') const { verifyRequest } = require('@shopify/koa-shopify-auth') const session = require('koa-session')dotenv.config()const { PORT, NODE_ENV, SHOPIFY_API_SECRET_KEY, SHOPIFY_API_KEY } = process.envconst port = parseInt(PORT, 10) || 3000 const dev = NODE_ENV !== 'production' const app = next({ dev }) const handle = app.getRequestHandler()app.prepare().then(() => { const server = new Koa() server.use(session({ secure: true, sameSite: 'none' }, 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.cookies.set('shopOrigin', shop, { httpOnly: false, secure: true, sameSite: 'none', }) ctx.redirect('/') }, }) )server.use(verifyRequest()) server.use(async (ctx) => { await handle(ctx.req, ctx.res) ctx.respond = false ctx.res.statusCode = 200 return }) server.listen(port, () => { console.log(`> Ready on http://localhost:${port}`) }) }) ```Can I set the dev variable somewhere (Idk much about koa) to code my app locally & then check the final result on Shopify app store?If you guys know how to set it, I'd appreciate any help. Or any other solution.I even tried serveo, lynk, sish & many other ngrok alternatives. None of them worked. serveo did until it didn't. So I gotta use 8 hours of ngrok but any other solutions are appreciated.
Submitted May 22, 2020 at 06:31AM by deadcoder0904
No comments:
Post a Comment