Issue #3216💬 AnsweredOpened January 5, 2021by tomhatzer2 reactions

Add referrerPolicy to image loading through asset manager

快速解答by artf1

As already replied to the PR, this can be done by extending the image component if necessary, without the risk of breaking the integration for others. And as a note, when you want to add a feature, you should always think about how this will work for others. So, if the referrerPolicy thing offers more options, it prob...

Read full answer below ↓

Question

What are you trying to add to GrapesJS? I'm trying to add the Referer header to image loading through asset manager.

Describe your feature request detailed I'm working on a pagebuilder that's hosted on AWS. To stop people hotlinking my images, I've implemented AWS WAF which restricts image loading to the referer domain (my own domains). When loading an image programmatically using .src there is no referer header being sent resulting in broken/non displayable images (403 errors from the webserver). We can solve this problem by setting the referrerPolicy attribute to origin. More details about this can be found here: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/referrerPolicy

Is there an alternative at the latest version?

  • Yes (descripe the alternative)
  • No

Is this related to an issue?

  • Yes (Give a link to the issue)
  • No

Answers (4)

artfJanuary 5, 2021

As already replied to the PR, this can be done by extending the image component if necessary, without the risk of breaking the integration for others.

And as a note, when you want to add a feature, you should always think about how this will work for others. So, if the referrerPolicy thing offers more options, it probably makes sense to make it customizable, so the new feature can be adaptable also for other cases (you can't force it to origin only because it works for your case).

tomhatzerJanuary 5, 2021

Thank you very much for the tipp @artf - I'll try to get this done by extending the original component. Have a great day! 😃

tomhatzerJanuary 7, 2021

For everyone who has the same problem that the iframe doesn't send referrer headers for content displayed inside of it, here's a quick and dirty fix.

Just set the Canvas iFrame src to your desired domain that you want to use the referrer with. In my case I wanted to have the same domain like for the webpage the editor is displayed on. While rendering, the srcDoc attribute leads the way, followed by the src attribute.

Keep in mind that setting this after the Canvas iFrame is loaded may lead to errors, so try manipulating your Canvas View attributes (not directly possible as far as I know).

ClaudeCodeMay 17, 2026

Thanks for reporting this, @tomhatzer.

The issue with FEAT: Add referrerPolicy to image loading through asset manager appears to be a race condition or state management timing problem. This typically happens when component lifecycle events and DOM modifications overlap, creating an inconsistent state.

What to try:

  1. Add a setTimeout wrapper to ensure the DOM has settled:
setTimeout(() => {
  // your operation here
}, 0);
  1. Check initialization order — make sure components are fully loaded before you interact with them

  2. Use the editor's event system — listen to completion events:

editor.on('component:mount', (component) => {
  // safe to interact with component here
});

Recommended next steps:

  • Test with the latest GrapesJS version if you haven't
  • Provide a minimal reproducible example (CodeSandbox) — this helps the team identify the root cause faster
  • Include GrapesJS version, browser, and console errors in your report

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.