Skip to content

Commit

Permalink
Merge branch 'main' into v2-preferstatic
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt authored Nov 28, 2023
2 parents d3aba0c + c9dcf30 commit 4021bc1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,10 @@ const onRequest = async (
? null
: await createStreamPromise(req, BYTES_LIMIT)

if (isImageRequest(req)) {
return imageProxy(req, res)
}

const edgeFunctionsProxyURL = await edgeFunctionsProxy(req, res)

if (edgeFunctionsProxyURL !== undefined) {
Expand Down Expand Up @@ -762,10 +766,6 @@ const onRequest = async (
return proxy.web(req, res, { target: functionsServer })
}

if (isImageRequest(req)) {
return imageProxy(req, res)
}

proxy.web(req, res, options)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default () => new Response(`you were shadowed!`)

export const config = {
path: '/.netlify/images',
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions tests/integration/commands/dev/v2-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,11 @@ describe.runIf(gte(version, '18.13.0'))('v2 api', () => {
expect(body.data).toBe('hello world')
expect(body.metadata).toEqual({ name: 'Netlify', features: { blobs: true, functions: true } })
})

test<FixtureTestContext>('does not shadow Image CDN', async ({ devServer }) => {
const response = await fetch(`http://localhost:${devServer.port}/.netlify/images?url=test.png&fm=avif`)
expect(response.status).toBe(200)
expect(response.headers.get('content-type')).toBe('image/avif')
})
})
})

0 comments on commit 4021bc1

Please sign in to comment.