Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
馃悰 Fixed missing source + resized images producing rendered 404 (#19869)
fixes https://linear.app/tryghost/issue/ENG-746/http-500-responses-when-handle-image-sizes-middleware-hits-missing - in the event a request comes in for a resized image, but the source image does not exist, we return a rendered 404 page - we do this because we pass the NotFoundError to `next`, which skips over the static asset code where we return a plaintext 404 - also included a breaking test that ensure we go to the next middleware without an error
- Loading branch information
1 parent
3f27ca5
commit 134c33c
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const assert = require('assert/strict'); | ||
const {agentProvider} = require('../utils/e2e-framework'); | ||
|
||
describe('Static files', function () { | ||
let frontendAgent; | ||
let ghostServer; | ||
|
||
before(async function () { | ||
const agents = await agentProvider.getAgentsWithFrontend(); | ||
frontendAgent = agents.frontendAgent; | ||
ghostServer = agents.ghostServer; | ||
}); | ||
|
||
after(async function () { | ||
await ghostServer.stop(); | ||
}); | ||
|
||
it('serves unstyled 404 for non-existing resized + original files', async function () { | ||
const response = await frontendAgent | ||
.get('/content/images/size/w2000/1995/12/daniel.jpg') | ||
.expect(404); | ||
|
||
assert.ok(response.text.includes('NotFoundError: Image not found')); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters