Skip to content

Commit c5f0215

Browse files
Arjan Singhtomdale
authored andcommitted
Send 404s for not found assets. (#25)
1 parent 840ec2c commit c5f0215

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/express-http-server.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class ExpressHTTPServer {
3737
if (this.distPath) {
3838
app.get('/', middleware);
3939
app.use(express.static(this.distPath));
40+
app.get('/assets/*', function(req, res) {
41+
res.sendStatus(404);
42+
});
4043
}
4144

4245
app.get('/*', middleware);

test/app-server-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ describe("FastBootAppServer", function() {
5656
});
5757
});
5858

59+
it("returns a 404 status code for non-existent assets", function() {
60+
return runServer('basic-app-server')
61+
.then(() => request('http://localhost:3000/assets/404-does-not-exist.js'))
62+
.then(response => {
63+
expect(response.statusCode).to.equal(404);
64+
expect(response.body).to.match(/Not Found/);
65+
})
66+
.then(() => request('http://localhost:3000/'))
67+
.then(response => {
68+
expect(response.statusCode).to.equal(200);
69+
expect(response.body).to.contain('Welcome to Ember');
70+
});
71+
});
72+
5973
});
6074

6175
function runServer(name) {

0 commit comments

Comments
 (0)