From d1d377bdd9483710a42fb5f4f40f4783f7550ae0 Mon Sep 17 00:00:00 2001 From: BatAmar Battulga Date: Mon, 17 Aug 2020 20:19:14 +0800 Subject: [PATCH] erxes/erxes#2223 --- src/middlewares/widgetsMiddleware.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/middlewares/widgetsMiddleware.ts b/src/middlewares/widgetsMiddleware.ts index 262cc7bca..92bcc0542 100644 --- a/src/middlewares/widgetsMiddleware.ts +++ b/src/middlewares/widgetsMiddleware.ts @@ -1,6 +1,9 @@ +import { getSubServiceDomain } from '../data/utils'; import { Scripts } from '../db/models'; const widgetsMiddleware = async (req, res) => { + const domain = getSubServiceDomain({ name: 'WIDGETS_DOMAIN' }); + const script = await Scripts.findOne({ _id: req.query.id }); if (!script) { @@ -11,7 +14,7 @@ const widgetsMiddleware = async (req, res) => { return ` (function() { var script = document.createElement('script'); - script.src = "${req.headers.origin}/build/${type}Widget.bundle.js"; + script.src = "${domain}/build/${type}Widget.bundle.js"; script.async = true; var entry = document.getElementsByTagName('script')[0];