我可以启动我的烬/rails服务器通过运行成员服务-代理http://localhost:3000。
为了将这个应用程序推到生产服务器上,我创建了一个占卜帐户,但是在将url传递给我的json时遇到了困难。
//divshot.json
{
"name": "project-name",
"root": "./dist",
"routes": {
"/tests": "tests/index.html",
"/tests/**": "tests/index.html",
"/**": "index.html"
},
"proxy": {
"origin": "https://railsapi.herokuapp.com/"
}
}
//environment.js
/* jshint node: true */
module.exports = function(environment) {
var ENV = {
modulePrefix: 'project-name',
environment: environment,
baseURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
}
},
APP: {
// Here you can pass flags/options to your application instance
// when it is created
}
};
if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
}
if (environment === 'test') {
// Testem prefers this...
ENV.baseURL = '/';
ENV.locationType = 'none';
// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
}
if (environment === 'production') {
}
return ENV;
};如何将应用程序推送到占卜和使用我在其他地方托管的api?
成员-cli 1.8.1 - 链接到有问题的项目
发布于 2015-02-23 18:53:45
我完全没有意识到迪夫肖特有这个服务。太棒了。
查看医生们,您似乎需要将代理置于一个命名密钥之下。
在他们的例子中是"api"
{
"proxy": {
"api": {
"origin":"https://api.my-app.com",
"headers": {
"Accept": "application/json"
},
"cookies": false,
"timeout": 30
}
}
}并通过表单/__/proxy/{NAME}/{PATH}的特殊URL访问它。
$.ajax({
url: '/__/proxy/api/users/123',
type: 'POST',
dataType: 'json',
success: function(data) {
// ...
}
})编辑:
我忽略了你的Ember应用程序的实际配置。
您需要在config/environment.js中设置API前缀。
在本地开发中,前缀将是'',而在Divshot上,前缀是/__/proxy/api。
在config/environment.js中,我喜欢这样做:
module.exports = function(environment) {
// Snip...
ENV.API_PREFIX: process.env.API_PREFIX || '',
};然后您可以在app/adapters/application.js中使用这个值,如下所示:
import DS from 'ember-data';
import config from '../config/environment';
export default DS.ActiveModelAdapter.extend({
host: config.apiUrl
});并在命令行上指定如下所示的API_PREFIX:
$ API_PREFIX="/__/proxy/api" ember build
$ divshot push希望这能帮上忙!
https://stackoverflow.com/questions/28680747
复制相似问题