@astrojs/cloudflare 0.2.0 → 0.2.1
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.
- package/CHANGELOG.md +6 -0
- package/README.md +8 -0
- package/dist/server.js +4 -0
- package/package.json +2 -2
- package/src/server.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @astrojs/cloudflare
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3695](https://github.com/withastro/astro/pull/3695) [`0d667d0e`](https://github.com/withastro/astro/commit/0d667d0e572d76d4c819816ddf51ed14b43e2551) Thanks [@nrgnrg](https://github.com/nrgnrg)! - fix custom 404 pages not rendering
|
|
8
|
+
|
|
3
9
|
## 0.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -22,3 +22,11 @@ $ pnpm install wrangler --save-dev
|
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"`
|
|
25
|
+
|
|
26
|
+
## Streams
|
|
27
|
+
|
|
28
|
+
Some integrations such as (react)[https://github.com/withastro/astro/tree/main/packages/integrations/react] rely on web streams. Currently Cloudflare Pages functions are in beta and don't support the `streams_enable_constructors` feature flag.
|
|
29
|
+
|
|
30
|
+
In order to work around this:
|
|
31
|
+
- install the `"web-streams-polyfill"` package
|
|
32
|
+
- add `import "web-streams-polyfill/es2018";` to the top of the front matter of every page which requires streams, such as server rendering a React component.
|
package/dist/server.js
CHANGED
|
@@ -11,6 +11,10 @@ function createExports(manifest) {
|
|
|
11
11
|
if (app.match(request)) {
|
|
12
12
|
return app.render(request);
|
|
13
13
|
}
|
|
14
|
+
const _404Request = new Request(`${origin}/404`, request);
|
|
15
|
+
if (app.match(_404Request)) {
|
|
16
|
+
return app.render(_404Request);
|
|
17
|
+
}
|
|
14
18
|
return new Response(null, {
|
|
15
19
|
status: 404,
|
|
16
20
|
statusText: "Not found"
|
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
|
+
"version": "0.2.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"esbuild": "^0.14.42"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"astro": "1.0.0-beta.
|
|
25
|
+
"astro": "1.0.0-beta.55",
|
|
26
26
|
"astro-scripts": "0.0.4"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
package/src/server.ts
CHANGED
|
@@ -24,6 +24,11 @@ export function createExports(manifest: SSRManifest) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// 404
|
|
27
|
+
const _404Request = new Request(`${origin}/404`, request);
|
|
28
|
+
if (app.match(_404Request)) {
|
|
29
|
+
return app.render(_404Request);
|
|
30
|
+
}
|
|
31
|
+
|
|
27
32
|
return new Response(null, {
|
|
28
33
|
status: 404,
|
|
29
34
|
statusText: 'Not found',
|