Ditch the global event handler as it wasn't the real solution. The real solution was to use window.parent in the API proxy