I have changed the domain name so in previous web hook was working correctly for product update and delete.But after changing he domain it is giving the error.I have reinstalled the app for registering webhook with new domain but not working.my code is below:-
import express from "express";
import serveStatic from "serve-static";
import shopify from "./shopify.js";
import webhookHooks from "./webhooks/webhook-handlers.js";
import Routes from "./routes/routes.js";
import RoutesStorefront from "./routes/routes-storefront.js";
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import dotenv from 'dotenv';
app.listen(PORT, () => {
console.log(Server is running on port ${PORT});
});
web/webhooks/webhook-handlers.js
import { DeliveryMethod } from "@shopify/shopify-api";
import productlistingController from '../controllers/productlisting.controller.js';
Hello @Mini-Sylar
I have changed the domain name so in previous web hook was working correctly for product update and delete.But after changing he domain it is giving the error.I have reinstalled the app for registering webhook with new domain but not working.my code is below:- import express from "express"; import serveStatic from "serve-static"; import shopify from "./shopify.js"; import webhookHooks from "./webhooks/webhook-handlers.js"; import Routes from "./routes/routes.js"; import RoutesStorefront from "./routes/routes-storefront.js"; import { fileURLToPath } from 'url'; import { dirname } from 'path'; import dotenv from 'dotenv';
dotenv.config();
const filename = fileURLToPath(import.meta.url); const dirname = dirname(__filename); const PORT = parseInt(process.env.BACKEND_PORT || process.env.PORT || "3000", 10); const STATIC_PATH = process.env.NODE_ENV === "production" ?
${process.cwd()}/frontend/dist
:${process.cwd()}/frontend/
; const app = express();//app.use(express.urlencoded({ limit: "50mb" }));
// Handle large payloads and URL-encoded data app.use(express.json({ limit: "50mb" })); app.use(express.urlencoded({ extended: true, limit: "50mb" }));
app.get(shopify.config.auth.path, shopify.auth.begin()); app.get( shopify.config.auth.callbackPath, shopify.auth.callback(), shopify.redirectToShopifyOrAppRoot() );
app.post( shopify.config.webhooks.path, shopify.processWebhooks({ webhookHandlers: webhookHooks }), (err, _req, res, _next) => { console.error("Failed to process webhook:", err); res.status(500).send("Failed to process webhook"); } );
app.use((req, res, next) => { res.header('Access-Control-Allow-Origin', ''); res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'); res.header('Access-Control-Allow-Headers', 'Content-Type'); next(); }); app.use(express.json({ limit: "50mb" })); app.use("/api/", shopify.validateAuthenticatedSession()); app.use('/api/v1', Routes); app.use('/storefront/v1', RoutesStorefront);
app.use(shopify.cspHeaders()); app.use(serveStatic(STATIC_PATH, { index: false }));
app.use("/*", shopify.ensureInstalledOnShop(), async (_req, res, _next) => { return res .status(200) .set("Content-Type", "text/html") .sendFile(STATIC_PATH + "/index.html"); });
app.listen(PORT, () => { console.log(
Server is running on port ${PORT}
); }); web/webhooks/webhook-handlers.js import { DeliveryMethod } from "@shopify/shopify-api"; import productlistingController from '../controllers/productlisting.controller.js';/**