Viewer API access via iframe

We’re subscribed to the PLUS plan which has access to the viewer API and custom domains.

I have an embedded iframe in my web app that displays the scene (the src attribute is a url to the shapespark scene), but CORS is preventing access to the Viewer API via the iframe. I tried using the custom domain option to use a subdomain name of our existing domain with hopes the CORS rules would be relaxed and allow access to the iframe contents, but it’s blocked that way as well.

How exactly is the Viewer API accessed when using an embedded iframe? Documentation describes being able to insert custom HTML into the scene, but I assume this works only when using the offline editor. This isn’t an option on our end.

Self-hosting on the same domain would for sure allow access to the embedded iframe, but I’m looking for options that don’t require upgrading to the Premium plan.

Is the only way to access the viewer API with the Plus plan via custom HTML embedded using the offline editor?

In the past using Document.domain property allowed API access between two subdomains of the same domain, however the property is now deprecated.

As the above MDN page suggests, Window.postMessage can be used instead for cross-origin communication. You can find an example in Configurator Commands - #10 by jan.

Hi Wojtek,

Thanks for your reply. I am working with Redline on this project. Our hope was to be able to control Shapespark hosted models without having to customize index.html for each model and it appears from your reply that this is not presently possible. Maybe we can discuss potential for this in the future. In the meantime, to allow us to continue our efforts and prototyping we have upgraded to the Premium Shapespark plan and will self host. However after upgrading, I am unable to download scenes. Is this something you could help us troubleshoot? Thanks again.

Have you considered using body-end.html instead of index.html to inject your custom HTML/JS code to your scenes? It should be possible to have a single generic body-end.html that you could add to all your scenes in a forward compatible way (unlike with index.html that you might need to update from time to time).

Do you have the Shapespark desktop application installed? It is required to execute a scene download after you initiate the download in the cloud dashboard.

Thanks very much for your suggestions regarding body-end.html. I will share your reply with our developer.

Regarding downloading the scene, we have not yet got to the point of executing the scene as we are presently unable to download it (click the download button but nothing seems to happen).

Unfortunately, neither I nor our developer works with a Windows machine so we do not have Shapespark desktop installed.

Will it be possible to do local hosting without using Shapespark Desktop?

Is there an alternative method you might be able to provide to allow us to inject body-end.html into our scenes without using Shapespark Desktop?

Thanks very much

Unfortunately, I don’t see a way how you could experiment with body-end.html without using the Shapespark desktop application.

You could develop your customizations against a locally hosted bundle (using a HTTP server on your OS), but then to move these customizations to body-end.html and upload them to a scene hosted on the Shapespark infrastructure you would need the desktop application anyway.

Are you using a Mac? Do you or your developer use Parallels to run some Windows app?

Thanks for this reply. I am thinking we will develop our customisations with a locally hosted bundle first and then can pick up the conversation on ways to streamline the process.

But we can’t seem to download the scene bundle - when we click the download button nothing seems to happen. Your assistance is a appreciated so we can continue our work. Thanks again.

I’ve got the bundle download figured out… I now understand download makes the scene available to the Desktop version and from there you can download the bundle for self-hosting. There are a few things I’d like to discuss outside of this forum. Will an email sent to be received by your team? Thanks again.

Have you downloaded the scene through the “Download” action at or through the “Bundle” action available only in the desktop application. In the former case the scene is in the native Shapespark format, and can be edited and opened in the desktop application. In the latter case, the bundle is meant for hosting with a regular WWW server like Apache, nginx or Microsfot IIS.

Yes, an email to will be received by the team.

Hi @wojtek Thanks. This process all makes sense to me now that I have the desktop application active.

1 Like