astroidjs 0.9.1 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -342,10 +342,16 @@ export function generateAstroidWorker(config) {
342
342
  p("];");
343
343
  p();
344
344
  p("// Stream uploaded media back from R2 at MEDIA_BASE (self-hosted, no public bucket).");
345
+ p("//");
346
+ p("// Scoped by ORIGIN, not by path prefix: MEDIA_BASE is an origin, and a");
347
+ p('// `url.pathname` ("/web/foo.jpg") can never start with one. Comparing the two');
348
+ p("// against each other made the guard permanently false, so the route never ran");
349
+ p("// and every uploaded asset fell through to the site's 404 page. On the media");
350
+ p("// host the whole pathname is the R2 key.");
345
351
  p("const mediaAssetRoute: WorkerRoute<CloudflareEnv> = async (request, env) => {");
346
352
  p(" const url = new URL(request.url);");
347
- p(" if (!url.pathname.startsWith(`${MEDIA_BASE}/`)) return undefined;");
348
- p(" const key = decodeURIComponent(url.pathname.slice(MEDIA_BASE.length + 1));");
353
+ p(" if (url.origin !== MEDIA_BASE) return undefined;");
354
+ p(" const key = decodeURIComponent(url.pathname.slice(1));");
349
355
  p(" if (!key) return undefined;");
350
356
  p(" const obj = await env.MEDIA.get(key);");
351
357
  p(' if (!obj) return new Response("Not found", { status: 404 });');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astroidjs",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "Astroid — an opinionated meta-framework over Louise Toolkit and Astro for building editable, multi-editor sites on Cloudflare Workers.",
5
5
  "keywords": [
6
6
  "astro",
@@ -60,7 +60,7 @@
60
60
  "access": "public"
61
61
  },
62
62
  "dependencies": {
63
- "louise-toolkit": "0.25.2"
63
+ "louise-toolkit": "0.25.3"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/node": "^24.13.3",