Ember-cli proxy iframe request


I’m trying to download a file by injecting a hidden iframe.

The URL is generated from the ember-data adapter’s buildURL. It looks something like: /api/documents/1/download.

When this URL is accessed via XHR, it is correctly proxied but when loaded directly in the browser or iframe, the express server doesn’t proxy it but returns the ember app html.

How do I force ember-cli to proxy all /api requests?

I could manually build the URL so it directly goes to the backend, but I would’ve wanted it to be more dynamic and work when using proxy in dev mode and setting api host in prod.


I think what you’re after can be solved with ember g http-proxy --help


Thanks. It’s working now.

But right now, I hardcoded the backend URL in my server/proxies/api.js. Is there any way to make it depend on the value of the --proxy passed in when starting the server?


Had this same issue when trying to display pdf’s in an iframe

<object data={{url}} type="application/pdf"> instead of <iframe src={{url}}> seems to work.

Something about specifying type forces the request to be handled by ajax. ¯_(ツ)_/¯