【发布时间】:2016-04-04 20:56:42
【问题描述】:
适用于本地和 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
}
非常感谢您对解决错误的任何帮助。
【问题讨论】:
标签: ember.js nginx ember-cli-mirage