@astrojs/cloudflare 13.3.1 → 13.4.0

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.
@@ -2,6 +2,7 @@ import { imageConfig } from "astro:assets";
2
2
  import { isRemotePath } from "@astrojs/internal-helpers/path";
3
3
  import { isRemoteAllowed } from "@astrojs/internal-helpers/remote";
4
4
  import { env } from "cloudflare:workers";
5
+ import { fetchWithRedirects } from "astro/assets";
5
6
  const prerender = false;
6
7
  const GET = async ({ request }) => {
7
8
  try {
@@ -14,7 +15,10 @@ const GET = async ({ request }) => {
14
15
  if (!isRemoteAllowed(href, imageConfig)) {
15
16
  return new Response("Forbidden", { status: 403 });
16
17
  }
17
- response = await fetch(href, { redirect: "manual" });
18
+ response = await fetchWithRedirects({
19
+ url: href,
20
+ imageConfig
21
+ });
18
22
  } else {
19
23
  const sourceUrl = new URL(href, url.origin);
20
24
  if (sourceUrl.origin !== url.origin) {
@@ -88,7 +88,7 @@ function serverStart({
88
88
  host,
89
89
  base
90
90
  }) {
91
- const version = "13.3.1";
91
+ const version = "13.4.0";
92
92
  const localPrefix = `${colors.dim("\u2503")} Local `;
93
93
  const networkPrefix = `${colors.dim("\u2503")} Network `;
94
94
  const emptyPrefix = " ".repeat(11);
package/dist/index.js CHANGED
@@ -178,6 +178,7 @@ function createIntegration({
178
178
  "astro > piccolore",
179
179
  "astro > picomatch",
180
180
  "astro/app",
181
+ "astro/app/fetch/default-handler",
181
182
  "astro/assets",
182
183
  "astro/assets/runtime",
183
184
  "astro/assets/utils/inferRemoteSize.js",
@@ -1,6 +1,7 @@
1
1
  import { imageConfig } from "astro:assets";
2
2
  import { isRemotePath } from "@astrojs/internal-helpers/path";
3
3
  import { isRemoteAllowed } from "@astrojs/internal-helpers/remote";
4
+ import { fetchWithRedirects } from "astro/assets";
4
5
  const qualityTable = {
5
6
  low: 25,
6
7
  mid: 50,
@@ -14,9 +15,21 @@ async function transform(rawUrl, images, assets) {
14
15
  return new Response("Forbidden", { status: 403 });
15
16
  }
16
17
  const imageSrc = new URL(href, url.origin);
17
- const content = await (isRemotePath(href) ? fetch(imageSrc, { redirect: "manual" }) : assets.fetch(imageSrc));
18
- if (content.status >= 300 && content.status < 400) {
19
- return new Response("Not Found", { status: 404 });
18
+ let content;
19
+ if (isRemotePath(href)) {
20
+ try {
21
+ content = await fetchWithRedirects({
22
+ url: imageSrc,
23
+ imageConfig
24
+ });
25
+ if (!isRemoteAllowed(content.url, imageConfig)) {
26
+ return new Response("Forbidden", { status: 403 });
27
+ }
28
+ } catch {
29
+ return new Response("Not Found", { status: 404 });
30
+ }
31
+ } else {
32
+ content = await assets.fetch(imageSrc);
20
33
  }
21
34
  if (!content.body) {
22
35
  return new Response(null, { status: 404 });
@@ -16,6 +16,7 @@ export declare function setImageConfig(service: ImageServiceConfig | undefined,
16
16
  endpoint: {
17
17
  entrypoint: string;
18
18
  };
19
+ dangerouslyProcessSVG: boolean;
19
20
  domains: string[];
20
21
  remotePatterns: {
21
22
  protocol?: string | undefined;
@@ -34,6 +35,7 @@ export declare function setImageConfig(service: ImageServiceConfig | undefined,
34
35
  route: string;
35
36
  entrypoint?: string | undefined;
36
37
  };
38
+ dangerouslyProcessSVG: boolean;
37
39
  domains: string[];
38
40
  remotePatterns: {
39
41
  protocol?: string | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/cloudflare",
3
3
  "description": "Deploy your site to Cloudflare Workers",
4
- "version": "13.3.1",
4
+ "version": "13.4.0",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -51,7 +51,7 @@
51
51
  "@types/node": "^25.2.2",
52
52
  "cheerio": "1.2.0",
53
53
  "devalue": "^5.6.3",
54
- "astro": "6.2.2",
54
+ "astro": "6.3.0",
55
55
  "astro-scripts": "0.0.14"
56
56
  },
57
57
  "publishConfig": {
@@ -59,9 +59,8 @@
59
59
  },
60
60
  "scripts": {
61
61
  "dev": "astro-scripts dev \"src/**/*.ts\"",
62
- "build": "astro-scripts build \"src/**/*.ts\" --clean-dts && tsc",
62
+ "build": "astro-scripts build \"src/**/*.ts\" --clean-dts && tsc -b",
63
63
  "build:ci": "astro-scripts build \"src/**/*.ts\"",
64
- "test": "astro-scripts test --force-exit \"test/**/*.test.ts\"",
65
- "typecheck:tests": "tsc --build tsconfig.test.json"
64
+ "test": "astro-scripts test --force-exit \"test/**/*.test.ts\""
66
65
  }
67
66
  }