Ember Test and Multiple Proxy Paths

We are currently using Ember with multiple backends, and thus require multiple “proxies” – for example:

  • any traffic to /backend-one needs to get proxied to http://serverone/somewhere/
  • any traffic to /backend-two needs to get proxied to http://servertwo/somewhereelse/

Since ember server only supports (as far as I know) a single --proxy ..., we have (for better or worse) set this up by:

  • Creating a server/index.js file
  • In this file, doing a require('http-proxy').createProxyServer({}) and then an app.use(...) to enact the proxy for a given path. (The proxy/app.use is done twice, one for each path.)

Now, this may be completely the wrong methodology, but it is how it currently works (and it seems to work fine).

Unfortunately, this causes us a bit of a problem for acceptance tests – we would like to have our acceptance tests access a ‘real’ backend, and thus they need to use the proxy. However, when we fire up ember test, it does not seem to run the server/index.js file, which means our proxies don’t run.

Can someone tell me “you are doing this completely wrong” and point me in the right direction?

(As an aside, we are currently using Ember 2.18 – I know, it’s old, but the upgrade hasn’t happened yet :slight_smile: )

Thanks in advance!

1 Like

The way you configured the multiple proxies for development is fine, I would have done it the same.

The problem with the tests is that the server for running tests is totally separate from the server for dev, and yeah, it doesn’t respect your server/index.js.

It’s possible to add to the test middleware, but somewhat manual. You would make an in-repo addon and that addon can implement the testemMiddleware hook, and use that to install your proxies. You can see examples of how other addons are calling that hook here:


Thanks very much for the response! This gives me a route to go down.