2016-04-01 18 views
0

nginxのローカルページとgithubページで動作します。 nginxでも、ブラウザからjsonファイルを正しく取得できます.nginxのemberアプリケーション内にはありません。のみnginxの上でこのエラーにNginxがEmber.js経由でファイルを入手できない

export default Ember.Route.extend({ 
    model: function() { 
     return $.getJSON('data/contributors.json') 
    } 
}) 

結果:

server.js:76 Mirage: Your Ember app tried to GET 'data/contributors.json', but there was no route defined to handle this request. Define a route that matches this path in your mirage/config.js file. Did you forget to add your namespace? 

nginxの上の場所の設定:

location/{ 
      # First attempt to serve request as file, then 
      # as directory, then fall back to displaying a 404. 
      try_files $uri $uri/ =404; 
      # Uncomment to enable naxsi on this location 
      # include /etc/nginx/naxsi.rules 
      try_files $uri /index.html; 

    } 

    location /data { 
      try_files $uri /contributors.json 
    } 

設定/ environment.js

if (environment === 'internal') { 
ENV.baseURL = '/' 
ENV['ember-cli-mirage'] = { 
    enabled: true 
} 
ENV.mirageNamespace = '<ip address>' 
ENV.isProd = true 
ENV.isDemo = true 

}

エラーを解決するための助けがあれば幸いです。

答えて

0

あなたはMirageを有効にしています。これはネットワーク要求を傍受し、それ自体を処理しています。アプリをデプロイする場合は、--environment productionでビルドを実行する必要があります。デフォルトではMirageが無効になっています。

何らかの理由でMirageを手動で有効にしていても、この動作を望まない場合は、mirage/config.jsファイルの末尾にthis.passthrough()を追加して、要求が実際にネットワークに到達できるようにすることができます。

+0

私はこれを持っているが、それは動作しません。しかし、私が 'ember build'をやっただけでは、Nginxサーバは動作します...(私もenvironment.jsファイルを質問に追加しました) – Hillboy

+0

あなたのAPI/Emberデータアダプタのホストは、emberアプリケーションを提供しているドメイン以外に指定されていますか? ?もしそうなら、 'パススルー 'の呼び出しでそのドメインを指定する必要があります。 'this.passthrough( 'my.api.com/**')' –

関連する問題