1
votes

I'm currently using ember cli 0.1.3 for front end and rails 4.1.8 for backend. I'm using ember-simple-auth for authenticating users and I followed https://github.com/givanse/ember-cli-simple-auth-devise to set it up.

It works great locally but using ember server --proxy http://0.0.0.0:3000 but I cannot seem to set the proxy for the production environment.

I'm hosting both the ember and rails apps on Heroku. I found there was a proxy generator for Ember CLI so I used ember g http-proxy users http://"url"

this created servers/proxies/http:/url.js:

var proxyPath = '/users';

module.exports = function(app) {
  // For options, see:
  // https://github.com/nodejitsu/node-http-proxy
  var proxy = require('http-proxy').createProxyServer({});
  var path = require('path');

  app.use(proxyPath, function(req, res, next){
    // include root path in proxied request
    req.url = path.join(proxyPath, req.url);
    proxy.web(req, res, { target: 'http://url' });
  });
};

Now once pushed to heroku, the xhr request still points the the Ember host.

1

1 Answers

1
votes

ok it turns out I was thinking way too complicated all I had to do was add to whole url to the endpoint.

config/environment.js

ENV['simple-auth-devise'] = {
      serverTokenEndpoint:  'http://url/users/sign_in',
      crossOriginWhitelist: ['http://url/']
    };