2016-09-02 1 views
1

다음 자습서 페이지까지이 페이지 (https://guides.emberjs.com/v2.7.0/tutorial/installing-addons/)에 대한 자습서를 진행할 예정입니다. (실제로 튜토리얼을 마칠 때까지 따라합니다.)EmberJS Mirage 404 get/rentals 오류

모든 것이 잘 작동하는 것 같습니다. ✔
Ember 서버가 브라우저에서 올바르게 표시되고 표시됩니다. ✔
Ember 개발 빌드도 올바르게 표시됩니다. ✔

하지만 Ember 제작 빌드는 /rentals 404 오류입니다. ✖
생산 빌드에서이 404 오류를 해결하는 방법은 무엇입니까?

여기에/내 신기루 아무것도 여전히/임대료 404 오류를 변경하지 않는

export default function() { 

    // These comments are here to help you get started. Feel free to delete them. 

    /* 
    Config (with defaults). 

    Note: these only affect routes defined *after* them! 
    */ 

    // this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server 
    // this.namespace = ''; // make this `api`, for example, if your API is namespaced 
    // this.timing = 400;  // delay for each request, automatically set to 0 during testing 

    /* 
    Shorthand cheatsheet: 

    this.get('/posts'); 
    this.post('/posts'); 
    this.get('/posts/:id'); 
    this.put('/posts/:id'); // or this.patch 
    this.del('/posts/:id'); 

    http://www.ember-cli-mirage.com/docs/v0.2.x/shorthands/ 
    */ 

    this.get('/rentals', function(db, request) { 
    let rentals = [{ 
     type: 'rentals', 
     id: 1, 
     attributes: { 
      title: 'Grand Old Mansion', 
      owner: 'Veruca Salt', 
      city: 'San Francisco', 
      type: 'Estate', 
      bedrooms: 15, 
      image: 'https://upload.wikimedia.org/wikipedia/commons/c/cb/Crane_estate_(5).jpg' 
     } 
     }, { 
     type: 'rentals', 
     id: 2, 
     attributes: { 
      title: 'Urban Living', 
      owner: 'Mike Teavee', 
      city: 'Seattle', 
      type: 'Condo', 
      bedrooms: 1, 
      image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg' 
     } 
     }, { 
     type: 'rentals', 
     id: 3, 
     attributes: { 
      title: 'Downtown Charm', 
      owner: 'Violet Beauregarde', 
      city: 'Portland', 
      type: 'Apartment', 
      bedrooms: 3, 
      image: 'https://upload.wikimedia.org/wikipedia/commons/f/f7/Wheeldon_Apartment_Building_-_Portland_Oregon.jpg' 
     } 
     }]; 

    if(request.queryParams.city !== undefined) { 
     let filteredRentals = rentals.filter(function(i) { 
     return i.attributes.city.toLowerCase().indexOf(request.queryParams.city.toLowerCase()) !== -1; 
     }); 
     return { data: filteredRentals }; 
    } else { 
     return { data: rentals }; 
    } 
    }); 

} 

URL 접두사와 네임 스페이스를 config.js.

GET http://localhost/rentals 404 Not Found
"NetworkError: 404 Not Found - http://localhost/rentals "
Error while processing route: index Ember Data Request GET /rentals returned a 404

답변

3

엠버 - CLI-신기루가 생산 빌드에서 비활성화되어, 당신은 명시 적으로 설정에서 활성화해야합니다

if (environment === 'production') { 
    ENV['ember-cli-mirage'] = { 
    enabled: true 
    }; 
} 

Mirage Documentation

+0

나를 위해 작동하지 않았다 – Asqan