# Ember-cli proxy iframe request

**URL:** <https://discuss.emberjs.com/t/ember-cli-proxy-iframe-request/8332>\
**Category:** Ember CLI\
**Created:** [July 8, 2015, 3:05am UTC](https://discuss.emberjs.com/t/ember-cli-proxy-iframe-request/8332 "2015-07-08T03:05:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![engwan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/engwan/32/10434_2.png) [@engwan](https://discuss.emberjs.com/u/engwan)\
**Post date:** [July 8, 2015, 3:05am UTC](https://discuss.emberjs.com/t/ember-cli-proxy-iframe-request/8332/1 "2015-07-08T03:05:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jasonmit](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jasonmit/32/182_2.png) [@jasonmit](https://discuss.emberjs.com/u/jasonmit)\
**Post date:** [July 8, 2015, 3:45am UTC](https://discuss.emberjs.com/t/ember-cli-proxy-iframe-request/8332/2 "2015-07-08T03:45:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![engwan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/engwan/32/10434_2.png) [@engwan](https://discuss.emberjs.com/u/engwan)\
**Post date:** [July 8, 2015, 4:14am UTC](https://discuss.emberjs.com/t/ember-cli-proxy-iframe-request/8332/3 "2015-07-08T04:14:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Subtletree](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/subtletree/32/12719_2.png) [@Subtletree](https://discuss.emberjs.com/u/Subtletree)\
**Post date:** [January 28, 2018, 10:22pm UTC](https://discuss.emberjs.com/t/ember-cli-proxy-iframe-request/8332/4 "2018-01-28T22:22:26Z")

</div>

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. ¯\_(ツ)\_/¯
