@astrojs/cloudflare 7.7.0 → 7.7.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.
|
@@ -14,31 +14,25 @@ export function createExports(manifest) {
|
|
|
14
14
|
if (manifest.assets.has(pathname)) {
|
|
15
15
|
return env.ASSETS.fetch(request);
|
|
16
16
|
}
|
|
17
|
-
let routeData = app.match(request
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
waitUntil
|
|
23
|
-
context.waitUntil(promise);
|
|
24
|
-
},
|
|
25
|
-
env: env,
|
|
26
|
-
cf: request.cf,
|
|
27
|
-
caches: caches,
|
|
17
|
+
let routeData = app.match(request);
|
|
18
|
+
Reflect.set(request, Symbol.for('astro.clientAddress'), request.headers.get('cf-connecting-ip'));
|
|
19
|
+
const locals = {
|
|
20
|
+
runtime: {
|
|
21
|
+
waitUntil: (promise) => {
|
|
22
|
+
context.waitUntil(promise);
|
|
28
23
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
env: env,
|
|
25
|
+
cf: request.cf,
|
|
26
|
+
caches: caches,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
let response = await app.render(request, routeData, locals);
|
|
30
|
+
if (app.setCookieHeaders) {
|
|
31
|
+
for (const setCookieHeader of app.setCookieHeaders(response)) {
|
|
32
|
+
response.headers.append('Set-Cookie', setCookieHeader);
|
|
35
33
|
}
|
|
36
|
-
return response;
|
|
37
34
|
}
|
|
38
|
-
return
|
|
39
|
-
status: 404,
|
|
40
|
-
statusText: 'Not found',
|
|
41
|
-
});
|
|
35
|
+
return response;
|
|
42
36
|
};
|
|
43
37
|
return { default: { fetch } };
|
|
44
38
|
}
|
|
@@ -16,31 +16,25 @@ export function createExports(manifest) {
|
|
|
16
16
|
if (manifest.assets.has(pathname)) {
|
|
17
17
|
return env.ASSETS.fetch(request);
|
|
18
18
|
}
|
|
19
|
-
let routeData = app.match(request
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
waitUntil
|
|
25
|
-
context.waitUntil(promise);
|
|
26
|
-
},
|
|
27
|
-
env: context.env,
|
|
28
|
-
cf: request.cf,
|
|
29
|
-
caches: caches,
|
|
19
|
+
let routeData = app.match(request);
|
|
20
|
+
Reflect.set(request, Symbol.for('astro.clientAddress'), request.headers.get('cf-connecting-ip'));
|
|
21
|
+
const locals = {
|
|
22
|
+
runtime: {
|
|
23
|
+
waitUntil: (promise) => {
|
|
24
|
+
context.waitUntil(promise);
|
|
30
25
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
env: context.env,
|
|
27
|
+
cf: request.cf,
|
|
28
|
+
caches: caches,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
let response = await app.render(request, routeData, locals);
|
|
32
|
+
if (app.setCookieHeaders) {
|
|
33
|
+
for (const setCookieHeader of app.setCookieHeaders(response)) {
|
|
34
|
+
response.headers.append('Set-Cookie', setCookieHeader);
|
|
37
35
|
}
|
|
38
|
-
return response;
|
|
39
36
|
}
|
|
40
|
-
return
|
|
41
|
-
status: 404,
|
|
42
|
-
statusText: 'Not found',
|
|
43
|
-
});
|
|
37
|
+
return response;
|
|
44
38
|
};
|
|
45
39
|
return { onRequest, manifest };
|
|
46
40
|
}
|
package/dist/index.js
CHANGED
|
@@ -390,11 +390,14 @@ export default function createIntegration(args) {
|
|
|
390
390
|
/**
|
|
391
391
|
* These route types are candiates for being part of the `_routes.json` `include` array.
|
|
392
392
|
*/
|
|
393
|
+
let notFoundIsSSR = false;
|
|
393
394
|
const potentialFunctionRouteTypes = ['endpoint', 'page'];
|
|
394
395
|
const functionEndpoints = routes
|
|
395
396
|
// Certain route types, when their prerender option is set to false, run on the server as function invocations
|
|
396
397
|
.filter((route) => potentialFunctionRouteTypes.includes(route.type) && !route.prerender)
|
|
397
398
|
.map((route) => {
|
|
399
|
+
if (route.component === 'src/pages/404.astro' && route.prerender === false)
|
|
400
|
+
notFoundIsSSR = true;
|
|
398
401
|
const includePattern = '/' +
|
|
399
402
|
route.segments
|
|
400
403
|
.flat()
|
|
@@ -499,7 +502,11 @@ export default function createIntegration(args) {
|
|
|
499
502
|
const excludeStrategyLength = excludeStrategy
|
|
500
503
|
? excludeStrategy.include.length + excludeStrategy.exclude.length
|
|
501
504
|
: Infinity;
|
|
502
|
-
const winningStrategy =
|
|
505
|
+
const winningStrategy = notFoundIsSSR
|
|
506
|
+
? excludeStrategy
|
|
507
|
+
: includeStrategyLength <= excludeStrategyLength
|
|
508
|
+
? includeStrategy
|
|
509
|
+
: excludeStrategy;
|
|
503
510
|
await fs.promises.writeFile(new URL('./_routes.json', _config.outDir), JSON.stringify({
|
|
504
511
|
version: 1,
|
|
505
512
|
...winningStrategy,
|
package/package.json
CHANGED