wrangler 3.114.1 → 4.0.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.
- package/README.md +8 -4
- package/bin/wrangler.js +1 -1
- package/config-schema.json +113 -1193
- package/package.json +7 -9
- package/wrangler-dist/InspectorProxyWorker.js +4 -8
- package/wrangler-dist/InspectorProxyWorker.js.map +1 -1
- package/wrangler-dist/ProxyWorker.js +3 -6
- package/wrangler-dist/ProxyWorker.js.map +1 -1
- package/wrangler-dist/cli.d.ts +2 -163
- package/wrangler-dist/cli.js +6975 -11637
- package/templates/middleware/middleware-serve-static-assets.d.ts +0 -6
- package/templates/middleware/middleware-serve-static-assets.ts +0 -56
- package/wrangler-dist/cli.js.map +0 -7
@@ -1,56 +0,0 @@
|
|
1
|
-
/// <reference path="middleware-serve-static-assets.d.ts"/>
|
2
|
-
|
3
|
-
import manifest from "__STATIC_CONTENT_MANIFEST";
|
4
|
-
import {
|
5
|
-
getAssetFromKV,
|
6
|
-
MethodNotAllowedError,
|
7
|
-
NotFoundError,
|
8
|
-
serveSinglePageApp,
|
9
|
-
} from "@cloudflare/kv-asset-handler";
|
10
|
-
import { cacheControl, spaMode } from "config:middleware/serve-static-assets";
|
11
|
-
import type { Middleware } from "./common";
|
12
|
-
import type { Options } from "@cloudflare/kv-asset-handler";
|
13
|
-
import type * as kvAssetHandler from "@cloudflare/kv-asset-handler";
|
14
|
-
|
15
|
-
const ASSET_MANIFEST = JSON.parse(manifest);
|
16
|
-
|
17
|
-
const staticAssets: Middleware = async (request, env, ctx, middlewareCtx) => {
|
18
|
-
let options: Partial<Options> = {
|
19
|
-
ASSET_MANIFEST,
|
20
|
-
ASSET_NAMESPACE: env.__STATIC_CONTENT,
|
21
|
-
cacheControl: cacheControl,
|
22
|
-
mapRequestToAsset: spaMode ? serveSinglePageApp : undefined,
|
23
|
-
};
|
24
|
-
|
25
|
-
try {
|
26
|
-
const page = await (getAssetFromKV as typeof kvAssetHandler.getAssetFromKV)(
|
27
|
-
{
|
28
|
-
request,
|
29
|
-
waitUntil(promise) {
|
30
|
-
return ctx.waitUntil(promise);
|
31
|
-
},
|
32
|
-
},
|
33
|
-
options
|
34
|
-
);
|
35
|
-
|
36
|
-
// allow headers to be altered
|
37
|
-
const response = new Response(page.body, page);
|
38
|
-
|
39
|
-
response.headers.set("X-XSS-Protection", "1; mode=block");
|
40
|
-
response.headers.set("X-Content-Type-Options", "nosniff");
|
41
|
-
response.headers.set("X-Frame-Options", "DENY");
|
42
|
-
response.headers.set("Referrer-Policy", "unsafe-url");
|
43
|
-
response.headers.set("Feature-Policy", "none");
|
44
|
-
|
45
|
-
return response;
|
46
|
-
} catch (e) {
|
47
|
-
if (e instanceof NotFoundError || e instanceof MethodNotAllowedError) {
|
48
|
-
// if a known error is thrown then serve from actual worker
|
49
|
-
return await middlewareCtx.next(request, env);
|
50
|
-
}
|
51
|
-
// otherwise it's a real error, so throw it
|
52
|
-
throw e;
|
53
|
-
}
|
54
|
-
};
|
55
|
-
|
56
|
-
export default staticAssets;
|