mercredi 25 janvier 2017

ember crash from heroku-buildpack-static configuration in static.json

Recently, I learned how to make a rails and ember-cli app talk to one another thru these tutorials. Following these tutorials and got a rails-5 API-mode app (running on localhost:3000) and an ember app (running on localhost:4200) to talk to one another thru rails "active-model-seralizer" gem and embers "active-model-adapter" package.

Currently, I am trying to deploy these small rails and ember apps on heroku. The rails app deployed just fine and is sending JSON at a /monsters endpoint. The exact url that is sending this json is here http://ift.tt/2jxt3JR

For context this is what my embers-cli app/routes/application.js, which should consume this JSON, looks like

import Ember from 'ember';

export default Ember.Route.extend({
  model(){
    return this.store.findAll('monster');
  }
});

This is my ember monser.js model

import DS from 'ember-data';

export default DS.Model.extend({
  name: DS.attr('string'),
  level: DS.attr('string')
});

My ember application.js

import ActiveModelAdapter from 'active-model-adapter';

export default ActiveModelAdapter.extend();

And, finally, my my ember application.hbs

<h1>Hello World</h1>
<ul>

  <li> is level </li>

</ul>

However, I am having problems getting my deployed ember app to proxy its AJAX calls to my deployed rails server. When I was running my ember app locally I could specify its proxy to localhost:3000 and it ran perfectly. But now that it and the rails app are being deployed, I'm having problems getting the ember app to proxy correctly. I have been trying to update its proxy settings by following the documentation found here.

My approach has been to add a static.json file at the root of my ember-cli app that looks like this

{
  "root": "dist/",
  "proxies": {
    "/": {
      "origin": "http://ift.tt/2jxgYnY"
    }
  }
}

This configuration, however, breaks my ember app. When looking through my heroku logs I see this error

2017-01-25T02:34:16.533811+00:00 app[web.1]: Starting nginx...
2017-01-25T02:34:16.554911+00:00 app[web.1]: nginx: [emerg] duplicate location "/" in ./config/nginx.conf:64
2017-01-25T02:34:16.555713+00:00 app[web.1]: Process exited unexpectedly: nginx
2017-01-25T02:34:16.555900+00:00 app[web.1]: Going down, terminating child processes...
2017-01-25T02:34:16.674333+00:00 heroku[web.1]: State changed from starting to crashed
2017-01-25T02:34:16.640841+00:00 heroku[web.1]: Process exited with status 1

Which makes me believe that there's something wrong with my static.json configuration. What do I need to change in order for my deployed ember app to treat my deployed rails as its proxy?




Aucun commentaire:

Enregistrer un commentaire