0

Works on local and github pages but with nginx. Even on nginx I can properly get the json file from the browser, just not within the ember app on nginx.

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

Results in this error only on 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?

location config on 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

}

Any help in resolving the error is much appreciated.

4

1 回答 1

0

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

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

于 2016-04-01T22:30:40.040 回答