Question

Background We have two web applications hosted on different sub-domains. Application 1 is an internal admin system. Application 2 is a helpdesk system.

We can modify the source code of Application 1 but we have no access to modify Application 2.

The Goal To display a link against an order in Application 1 that will open a new window, the URL of which is that of a ticket in Application 2.

The idea being that our staff can see that an order has a helpdesk ticket raised against it and simply needs to click a link on the order to view the ticket and reply to it.

The problem Regardless of how I open the new window (window.open, target="_blank", etc.) the ticket in the new window is unable to make any ajax requests back to the helpdesk system where it is hosted.

The URL of the new window is part of Application 2.

In Google dev tools it tells me "The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "https". Protocols must match." even when I open it using _blank.

If I go to the exact same URL manually everything works... but this doesn't help when I need it to work from the link.

Is there any way to achieve the above?

If not, is there any way I can open a new window that is "detached" from the window that opened it so that same origin policy no longer applies?

Edit 2014-03-28 10:23 I have no access to App2's code at all. I cannot make any changes to App2. Any answer must take this into account.

I am trying to open a new window from my application (App1) where the target URL of that window is a page in App2. That page inside App2 then needs to be able to use ajax to communicate with other areas of App2. This is where the problem lies. Because App1 opened the window the same origin policy is preventing that window from making it's ajax requests.

Was it helpful?

Solution

I suspect that JavaScript on the second (helpdesk) app is trying to access the first app via window.opener (which could lead to the cross-origin error you're seeing) and subsequent JavaScript (fetching stuff via AJAX) is then not getting executed. You can probably narrow things down by setting appropriate breakpoints in the second app.

If this is the cause and you can't modify the source for the helpdesk app, how about going to a URL in the internal domain that would then redirect to the help desk? The redirect should cause the window.opener property to become null (same as manually typing in the URL).

Assuming https://admin.mydomain.co.uk and http://helpdesk.mydomain.co.uk, clicking on the "Help Ticket" link would go to a URL in the internal app, e.g. https://admin.mydomain.co.uk/getHelp?ticketId, which would respond with a 301 response and an appropriate Location: http://helpdesk.domain.uk/help/ticketId header taking the user to the actual helpdesk URL.

OTHER TIPS

You could use a proxy server or iframe proxying.

Use the following url //app2.mydomain.co.uk without the http or https.

It's not only a cross domain problem but a protocol issue : You can't embed https into http page without this warning.

Consider using iframe inside your App1 :

<iframe src="https://app2.mydomain.co.uk" ></iframe>

Or maybe you can use CORS to access data between your two domains ( but i think it's not the point, you want the whole App2 page, isn't it ? )

Edit : By re-reading your question, i'm pretty sure of two thing :

  • You're not looking at the right direction. You say App2 don't use SSL, and that obviously false when Chrome say "Protocols must match"
  • It's not a "attach" or "detached" problem. If you put a link (blank or not) in a page, it can be load the new page without any problem, nor link with the referal page.

So my guess is : Your are calling App2 without SSL ( no https), BUT inside the App2, there is some https involved ( certainly some ajax query). So here is the problem : When you open the page without https, it's seem to load, but when the first https Ajax fires, it fail.

Try using https when calling your App2 url, and give us the result

My solution is this: in Application 1 you create a method your method that calling Application 2 on the server side, then you can use AJAX calling your method which will return result of Application 2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top