How to use a custom Express server with Ember CLI?

后端 未结 2 1318
予麋鹿
予麋鹿 2020-12-24 09:51

I\'m using Ember CLI 0.0.36. When I run ember server in my project folder, my understanding is that a server buried in some Brocoli process gets started. Howeve

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-24 09:56

    I started playing with ember cli so i'm not sure but i found the following: https://github.com/dockyard/ember-cli-plus-backend/tree/rails-served-html/frontend/api-stub Basically you should proxy your express server to the same port as your ember-cli (so then you don't have to deal with jsonp issue)

    Set the method to 'proxy' and define the proxyURL to pass all API requests to the proxy URL.

    UPDATE:

    1.Generate adapter ember generate adapter application

    2.Make api namespace - fill the created file with the following code:

    export default DS.RESTAdapter.reopen({ namespace: 'api' });

    3.Start the server with ember serve --proxy http://localhost:1337/ (this will proxy all your request to localhost:4200 to 1337

    4.Make routes in your express app prefixed by /api

    Hope it helps

提交回复
热议问题