0
votes

Even after setting the host in the adapter in ember-cli the request is sent to the page domain:

adapters/students.js

import DS from 'ember-data';

export default DS.RESTAdapter.extend({
     host:"localhost:8080/Hello"
});

routes/students.js

import Ember from 'ember';

export default Ember.Route.extend({
     model: function(){
          return this.store.find('students');
     }
});

When the students template is loaded it sends the request to "localhost:4200/students" and gives an error GET localhost:4200/students 404 (Not Found). The app is served on localhost:4200, but the request should be sent to "localhost:8080/Hello/students".

1

1 Answers

2
votes

Your adapter file should be named adapters/application.js. You will also need to update the adapter file to something like this:

import DS from 'ember-data';

export default DS.RESTAdapter.extend({
    host: 'http://localhost:8080',
    namespace: 'Hello'
})

Also, make sure you are starting your application like this:

ember server --proxy http://localhost:8080