# Dashboard embeded iframe CORS issue

**URL:** <https://discuss.elastic.co/t/dashboard-embeded-iframe-cors-issue/271681>\
**Category:** Kibana\
**Created:** [April 29, 2021, 4:32pm UTC](https://discuss.elastic.co/t/dashboard-embeded-iframe-cors-issue/271681 "2021-04-29T16:32:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manuel\_Castro\_Romero](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manuel_castro_romero/32/84916_2.png) [@Manuel\_Castro\_Romero](https://discuss.elastic.co/u/Manuel_Castro_Romero)\
**Post date:** [April 29, 2021, 4:32pm UTC](https://discuss.elastic.co/t/dashboard-embeded-iframe-cors-issue/271681/1 "2021-04-29T16:32:03Z")

</div>

Tried to embed a kibana iframe into my SPA built with react.  
I try to adjusting the height of the iframe to fit with its content  
this is a code snips of who I am trying to do it:

```
const Iframe = ({ url }) => {
  const [iFrameHeight, setState] = useState(600);
  const iframe = useRef(null);    

    return (
    <>
    <iframe
      title="z"
      className=""
      onLoad={() => {         
        setState(            
            (iframe.current.contentWindow.document.body.scrollHeight+50)+ "px",
        );        
      }}
     
      ref="https://kibana.mydomain.co/app/dashboards#/view..."
      src={url}
      width="100%"
      height={iFrameHeight} 
      scrolling="no"
      frameBorder="0"
      crossOrigin="true"
    />
      </>
  );
};

```

basically I am trying to access the contentWindow.document in order to get the scroll height and adjust the content but I am getting this error:  
running the app om mozila:

> SecurityError: Permission denied to access property "document" on cross-origin object

running the app on chrome

> Blocked a frame with origin "[https://myapp.mydomain.co](https://myapp.mydomain.co)" from accessing a cross-origin frame.

---

<div class="post-metadata">

**Author:** ![Mikhail\_Shustov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikhail_shustov/32/49186_2.png) [@Mikhail\_Shustov](https://discuss.elastic.co/u/Mikhail_Shustov)\
**Post date:** [April 30, 2021, 11:01am UTC](https://discuss.elastic.co/t/dashboard-embeded-iframe-cors-issue/271681/2 "2021-04-30T11:01:36Z")

</div>

CORS is not enabled by default.  
Have you tried to enable it with `kibana.yml` file? See `server.cors.enabled`, `server.cors.allowCredentials` and `server.cors.allowOrigin` in

> **[Configure Kibana | Kibana Guide \[7.12\] | Elastic](https://www.elastic.co/guide/en/kibana/current/settings.html)**

---

<div class="post-metadata">

**Author:** ![Manuel\_Castro\_Romero](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manuel_castro_romero/32/84916_2.png) [@Manuel\_Castro\_Romero](https://discuss.elastic.co/u/Manuel_Castro_Romero)\
**Post date:** [May 4, 2021, 11:09am UTC](https://discuss.elastic.co/t/dashboard-embeded-iframe-cors-issue/271681/3 "2021-05-04T11:09:17Z")

</div>

thanks, I let you know if it works

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 1, 2021, 11:09am UTC](https://discuss.elastic.co/t/dashboard-embeded-iframe-cors-issue/271681/4 "2021-06-01T11:09:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
