@astrojs/cloudflare 0.2.4 → 0.3.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.
@@ -1,5 +1,5 @@
1
- @astrojs/cloudflare:build: cache hit, replaying output af6a8235acaf44a1
2
- @astrojs/cloudflare:build: 
3
- @astrojs/cloudflare:build: > @astrojs/cloudflare@0.2.4 build /home/runner/work/astro/astro/packages/integrations/cloudflare
4
- @astrojs/cloudflare:build: > astro-scripts build "src/**/*.ts" && tsc
5
- @astrojs/cloudflare:build: 
1
+ @astrojs/cloudflare:build: cache hit, replaying output 7d2a1e1c56d7ba86
2
+ @astrojs/cloudflare:build: 
3
+ @astrojs/cloudflare:build: > @astrojs/cloudflare@0.3.0 build /home/runner/work/astro/astro/packages/integrations/cloudflare
4
+ @astrojs/cloudflare:build: > astro-scripts build "src/**/*.ts" && tsc
5
+ @astrojs/cloudflare:build: 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @astrojs/cloudflare
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#4015](https://github.com/withastro/astro/pull/4015) [`6fd161d76`](https://github.com/withastro/astro/commit/6fd161d7691cbf9d3ffa4646e46059dfd0940010) Thanks [@matthewp](https://github.com/matthewp)! - New `output` configuration option
8
+
9
+ This change introduces a new "output target" configuration option (`output`). Setting the output target lets you decide the format of your final build, either:
10
+
11
+ - `"static"` (default): A static site. Your final build will be a collection of static assets (HTML, CSS, JS) that you can deploy to any static site host.
12
+ - `"server"`: A dynamic server application. Your final build will be an application that will run in a hosted server environment, generating HTML dynamically for different requests.
13
+
14
+ If `output` is omitted from your config, the default value `"static"` will be used.
15
+
16
+ When using the `"server"` output target, you must also include a runtime adapter via the `adapter` configuration. An adapter will _adapt_ your final build to run on the deployed platform of your choice (Netlify, Vercel, Node.js, Deno, etc).
17
+
18
+ To migrate: No action is required for most users. If you currently define an `adapter`, you will need to also add `output: 'server'` to your config file to make it explicit that you are building a server. Here is an example of what that change would look like for someone deploying to Netlify:
19
+
20
+ ```diff
21
+ import { defineConfig } from 'astro/config';
22
+ import netlify from '@astrojs/netlify/functions';
23
+
24
+ export default defineConfig({
25
+ adapter: netlify(),
26
+ + output: 'server',
27
+ });
28
+ ```
29
+
30
+ * [#4018](https://github.com/withastro/astro/pull/4018) [`0cc6ede36`](https://github.com/withastro/astro/commit/0cc6ede362996b9faba57481a790d6eb7fba2045) Thanks [@okikio](https://github.com/okikio)! - Support for 404 and 500 pages in SSR
31
+
32
+ - [#3973](https://github.com/withastro/astro/pull/3973) [`5a23483ef`](https://github.com/withastro/astro/commit/5a23483efb3ba614b05a00064f84415620605204) Thanks [@matthewp](https://github.com/matthewp)! - Adds support for Astro.clientAddress
33
+
34
+ The new `Astro.clientAddress` property allows you to get the IP address of the requested user.
35
+
36
+ ```astro
37
+ <div>Your address { Astro.clientAddress }</div>
38
+ ```
39
+
40
+ This property is only available when building for SSR, and only if the adapter you are using supports providing the IP address. If you attempt to access the property in a SSG app it will throw an error.
41
+
3
42
  ## 0.2.4
4
43
 
5
44
  ### Patch Changes
package/README.md CHANGED
@@ -9,6 +9,7 @@ import { defineConfig } from 'astro/config';
9
9
  import cloudflare from '@astrojs/cloudflare';
10
10
 
11
11
  export default defineConfig({
12
+ output: 'server',
12
13
  adapter: cloudflare()
13
14
  });
14
15
  ```
package/dist/index.js CHANGED
@@ -17,6 +17,14 @@ function createIntegration() {
17
17
  "astro:config:done": ({ setAdapter, config }) => {
18
18
  setAdapter(getAdapter());
19
19
  _config = config;
20
+ if (config.output === "static") {
21
+ console.warn(
22
+ `[@astrojs/cloudflare] \`output: "server"\` is required to use this adapter.`
23
+ );
24
+ console.warn(
25
+ `[@astrojs/cloudflare] Otherwise, this adapter is not required to deploy a static site to Cloudflare.`
26
+ );
27
+ }
20
28
  },
21
29
  "astro:build:start": ({ buildConfig }) => {
22
30
  _buildConfig = buildConfig;
package/dist/server.js CHANGED
@@ -8,12 +8,14 @@ function createExports(manifest) {
8
8
  const assetRequest = new Request(`${origin}/static${pathname}`, request);
9
9
  return env.ASSETS.fetch(assetRequest);
10
10
  }
11
- if (app.match(request)) {
12
- return app.render(request);
13
- }
14
- const _404Request = new Request(`${origin}/404`, request);
15
- if (app.match(_404Request)) {
16
- return app.render(_404Request);
11
+ let routeData = app.match(request, { matchNotFound: true });
12
+ if (routeData) {
13
+ Reflect.set(
14
+ request,
15
+ Symbol.for("astro.clientAddress"),
16
+ request.headers.get("cf-connecting-ip")
17
+ );
18
+ return app.render(request, routeData);
17
19
  }
18
20
  return new Response(null, {
19
21
  status: 404,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/cloudflare",
3
3
  "description": "Deploy your site to cloudflare pages functions",
4
- "version": "0.2.4",
4
+ "version": "0.3.0",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -25,7 +25,7 @@
25
25
  "esbuild": "^0.14.42"
26
26
  },
27
27
  "devDependencies": {
28
- "astro": "1.0.0-beta.69",
28
+ "astro": "1.0.0-rc.1",
29
29
  "astro-scripts": "0.0.6"
30
30
  },
31
31
  "scripts": {
package/src/index.ts CHANGED
@@ -21,6 +21,15 @@ export default function createIntegration(): AstroIntegration {
21
21
  'astro:config:done': ({ setAdapter, config }) => {
22
22
  setAdapter(getAdapter());
23
23
  _config = config;
24
+
25
+ if (config.output === 'static') {
26
+ console.warn(
27
+ `[@astrojs/cloudflare] \`output: "server"\` is required to use this adapter.`
28
+ );
29
+ console.warn(
30
+ `[@astrojs/cloudflare] Otherwise, this adapter is not required to deploy a static site to Cloudflare.`
31
+ );
32
+ }
24
33
  },
25
34
  'astro:build:start': ({ buildConfig }) => {
26
35
  _buildConfig = buildConfig;
package/src/server.ts CHANGED
@@ -19,14 +19,14 @@ export function createExports(manifest: SSRManifest) {
19
19
  return env.ASSETS.fetch(assetRequest);
20
20
  }
21
21
 
22
- if (app.match(request)) {
23
- return app.render(request);
24
- }
25
-
26
- // 404
27
- const _404Request = new Request(`${origin}/404`, request);
28
- if (app.match(_404Request)) {
29
- return app.render(_404Request);
22
+ let routeData = app.match(request, { matchNotFound: true });
23
+ if (routeData) {
24
+ Reflect.set(
25
+ request,
26
+ Symbol.for('astro.clientAddress'),
27
+ request.headers.get('cf-connecting-ip')
28
+ );
29
+ return app.render(request, routeData);
30
30
  }
31
31
 
32
32
  return new Response(null, {