Nginx无法通过Ember.js获取路径上可用的文件

Nginx无法通过Ember.js获取路径上可用的文件,ember.js,nginx,ember-cli-mirage,Ember.js,Nginx,Ember Cli Mirage,适用于本地和github页面,但使用nginx。即使在nginx上,我也可以从浏览器中正确地获取json文件,只是不在nginx上的ember应用程序中 export default Ember.Route.extend({ model: function () { return $.getJSON('data/contributors.json') } }) 仅在Nginx上导致此错误: server.js:76 Mirage: Your Ember app tried

适用于本地和github页面,但使用nginx。即使在nginx上,我也可以从浏览器中正确地获取json文件,只是不在nginx上的ember应用程序中

export default Ember.Route.extend({
  model: function () {
      return $.getJSON('data/contributors.json')
  }
})
仅在Nginx上导致此错误:

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
    }
config/environment.js

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


非常感谢您对解决此错误的任何帮助。

您启用了Mirage,它可以拦截网络请求并自行处理。如果你正在部署你的应用程序,你应该使用
--environment production
进行构建,默认情况下它会禁用Mirage

如果出于某种原因手动启用Mirage,但不希望出现这种行为,则可以在
Mirage/config.js
文件的底部添加
this.passthrough()
,以允许请求实际到达网络


我有这个,但不起作用。如果我只进行
ember构建
,Nginx服务器确实可以工作。。。(我还将我的environment.js文件添加到了问题中)您的API/Ember数据适配器的主机是否被指定为除为Ember应用程序提供服务的域之外的其他对象?如果是这样,您需要在调用
passthrough
时指定该域,例如
this.passthrough('my.api.com/**')