Skip to content

Commit 86a65bb

Browse files
fix(cdn): return 404 for packages not in R2 bucket
micropip iterates index_urls in order and stops at the first 200. Returning 200 with empty HTML for unknown packages prevented fallthrough to PyPI. Return 404 instead so micropip continues to the next index.
1 parent 72d8048 commit 86a65bb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

worker/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export default {
1616
const pkgName = path.slice('/cdn/simple/'.length).replace(/\/$/, '')
1717
if (!pkgName) return new Response('Not Found', { status: 404 })
1818
const listed = await env.CDN_BUCKET.list({ prefix: `${pkgName}/` })
19+
if (listed.objects.length === 0)
20+
return new Response('Not Found', { status: 404, headers: { 'Access-Control-Allow-Origin': '*' } })
1921
const links = listed.objects
2022
.map(obj => {
2123
const filename = obj.key.split('/').pop()

0 commit comments

Comments
 (0)