Hashnode / starter-kit

A blog starter kit to use Hashnode as a Headless CMS using GraphQL APIs.
https://hashnode.com/headless
MIT License
524 stars 774 forks source link

iFrame Script Source URL #163

Open megabyte0x opened 4 months ago

megabyte0x commented 4 months ago

Disclaimer: I am not sure how important this issue is 😅

Problem

Currently, in the packages/utils/renderer/services/embed.ts the script src is constant that is, /js/iframe-resizer.js which do not work if NEXT_PUBLIC_BASE_URL is defined.

Potential Solution

Make the script.src dynamic with NEXT_PUBLIC_BASE_URL

const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL || '';

script.src = BASE_URL == '' ? `/js/iframe-resizer.js` : `${BASE_URL}/js/iframe-resizer.js`;