Skip to main content
Question

How to add an inframe into a custom view?


Obed Murillo
Forum|alt.badge.img+3

I learned that you can have a preview into MC with a Custom View.

I saw this on a post on linkedIn:

And I naturally tried it, but got an exception:

 

Does any of you know where do I need to configure to support iframes from a different domain?

 

If not answer I’ll create a support ticket...

 

Regards,

Obed
 

 

pauloamgomes
Forum|alt.badge.img+3

Obed Murillo
Forum|alt.badge.img+3

Yes I did, but still no luck, according to the AI assistant this is not possible… :(


Lily
Forum|alt.badge.img+2
  • Community Manager
  • August 12, 2024

@Obed Murillo would you like me to get in touch with the support team?


Philipp Hofmann
commercetooler
Forum|alt.badge.img+1

Hey @Obed Murillo ,
I guess what you are looking for is:
 

headers: {
  csp: {
    'connect-src': [
      '*.frontend.site',
    ],
    'frame-src': [
      '*.frontend.site',
    ],
  }
},

 

as described here: https://docs.commercetools.com/merchant-center-customizations/api-reference/custom-view-config#headerscsp

Does that help?


Obed Murillo
Forum|alt.badge.img+3

Thanks @Philipp Hofmann !

I think this is what I was missing.

Let me try and I’ll get back with you!

Regards,

Obed


Obed Murillo
Forum|alt.badge.img+3

Thanks for the help @Philipp Hofmann ,

I had that setting set, but was still failing with the same error, the issue was on the site I was trying to add as preview, it was having the following setting:

async headers() {
    return [
      {
        // This will set the X-Frame-Options header to "SAMEORIGIN" for all pages
        source: '/:path*',
        headers: [
          {
            key: 'X-Frame-Options',
            value: 'SAMEORIGIN', 
          },
        ],
      },
    ];
}

So I changed it to be as follows:

async headers() {
    return [
      {
        // This will set the X-Frame-Options header
        source: '/:path*',
        headers: [
          {
            key: 'X-Frame-Options',
            value: 'ALLOW-FROM https://mc.us-central1.gcp.commercetools.com', 
          },
        ],
      },
    ];
}

Good thing we learned that is possible to add a preview on MC :D

Thank you All!

 


Philipp Hofmann
commercetooler
Forum|alt.badge.img+1

Really cool. What is it that you are building? An integrated preview as shown in the screenshot in your first post?


Obed Murillo
Forum|alt.badge.img+3

@Philipp Hofmann 

This was just a POC to see the custom views in action.

But yes is a preview of the site we are building

Sorry for the late response.

Regards,

Obed


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings