Skip to content
This repository has been archived by the owner on Nov 21, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
batamar committed Aug 17, 2020
1 parent c18e5a9 commit d1d377b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/middlewares/widgetsMiddleware.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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];
Expand Down

0 comments on commit d1d377b

Please sign in to comment.