I am trying to access the Confluence REST API from my Backbone application on an Atlassian Connect Express server. I get my application up and running but when I try to fetch data from the REST API I get the following error message:
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://localhost:1990') does not match the recipient window's origin ('http://localhost:3000').
My guess is that this is by design of the browser since accessing a JIRA resource on my 1990-port from the site on port 3000 is not allowed? Do I have to configure this configuration in the atlassian-connect.json or how does it work? Do I really have to use the modules provided that renders my app as an iframe (I use the webItem module at the moment)?
All help is greatly appreciated.
Cheers!
Community moderators have prevented the ability to post new answers.
Since your Connect app runs inside an iframe, a normal AJAX request is cross domain and likely the source of your error. If you instead use AP.request to make the request, it will be bridged across to the host product and not be a cross domain request.
It doesn't matter what or where the content is in the Atlassian Connect app, as all in production content is rendered in an iframe within Confluence.
Thanks for your swift answer Travis! I do use AP.request, i override my Backbone.sync with something like this: AP.require('request', function(request){ request ({ url: '...', //..., success: function() { ... } }); }); I'd expect that to produce the same result right? By the way, my app is not running inside an iframe at the moment, I use the webItem module to produce a link to my app in the top-bar. I'm starting to suspect this is the wrong way of doing it...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, if you have a link to your add-on that doesn't exist as an iframe, you'll need to proxy all the calls through the backend (ACE) to Confluence rather than doing direct calls to the product. This explains the postMessage complaint. Nothing AP will work without the iframe since it makes a call to the parent frame (and there isn't one).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, kind of hard calling the parent frame then! :) I guess I'm missing something obvious here but I have tried to google for some tips on how to do the proxy via backend, could you please give me a hint? As an alternative, is it possible to render my add-on in a full screen iframe inside of confluence, i.e covering the whole browser window with an iframe containing my stuff?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should be able to create a dialog that's 100% high/wide: https://developer.atlassian.com/static/connect/docs/javascript/module-Dialog.html. You might want to use 100vh instead of 100% for height though.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.