nuxt-skew-protection 1.4.1 → 1.4.2
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/dist/module.json +1 -1
- package/dist/module.mjs +13 -1
- package/package.json +2 -2
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -194,6 +194,10 @@ const legacyCloudflareAdapterSuffixes = [
|
|
|
194
194
|
"/nitropack/dist/runtime/entries/cloudflare.mjs",
|
|
195
195
|
"/nitropack/dist/runtime/entries/cloudflare-pages.mjs"
|
|
196
196
|
];
|
|
197
|
+
const nitroPrerenderEntrySuffix = "/nitropack/dist/presets/_nitro/runtime/nitro-prerenderer.mjs";
|
|
198
|
+
function isNitroPrerenderEntry(id) {
|
|
199
|
+
return id.split("?", 1)[0].endsWith(nitroPrerenderEntrySuffix);
|
|
200
|
+
}
|
|
197
201
|
function isLegacyCloudflareEntry(id) {
|
|
198
202
|
const normalizedId = id.split("?", 1)[0].replaceAll("\\", "/");
|
|
199
203
|
return legacyCloudflareAdapterSuffixes.some((suffix) => normalizedId.endsWith(suffix));
|
|
@@ -225,20 +229,28 @@ export default {
|
|
|
225
229
|
function createCloudflareAssetProtectionPlugin(options) {
|
|
226
230
|
let nitroEntryId;
|
|
227
231
|
let wrapperLoaded = false;
|
|
232
|
+
let shouldWrapEntry = true;
|
|
228
233
|
return {
|
|
229
234
|
name: "nuxt-skew-protection:cloudflare-asset-fetch",
|
|
230
235
|
options(inputOptions) {
|
|
236
|
+
nitroEntryId = void 0;
|
|
237
|
+
wrapperLoaded = false;
|
|
238
|
+
shouldWrapEntry = false;
|
|
231
239
|
if (typeof inputOptions.input !== "string") {
|
|
232
240
|
this.error(
|
|
233
241
|
"[nuxt-skew-protection] Asset 404 protection requires one Nitro entry."
|
|
234
242
|
);
|
|
235
243
|
}
|
|
244
|
+
if (isNitroPrerenderEntry(inputOptions.input)) {
|
|
245
|
+
return inputOptions;
|
|
246
|
+
}
|
|
236
247
|
if (isLegacyCloudflareEntry(inputOptions.input)) {
|
|
237
248
|
this.error(
|
|
238
249
|
"[nuxt-skew-protection] Asset 404 protection requires nitropack >= 2.10.0. Your project uses an older adapter without the ASSETS binding. Upgrade nitropack (or nuxt) to enable asset 404 protection."
|
|
239
250
|
);
|
|
240
251
|
}
|
|
241
252
|
nitroEntryId = inputOptions.input;
|
|
253
|
+
shouldWrapEntry = true;
|
|
242
254
|
return {
|
|
243
255
|
...inputOptions,
|
|
244
256
|
input: virtualEntryId
|
|
@@ -258,7 +270,7 @@ function createCloudflareAssetProtectionPlugin(options) {
|
|
|
258
270
|
});
|
|
259
271
|
},
|
|
260
272
|
buildEnd(error) {
|
|
261
|
-
if (!error && !wrapperLoaded) {
|
|
273
|
+
if (shouldWrapEntry && !error && !wrapperLoaded) {
|
|
262
274
|
this.error(
|
|
263
275
|
"[nuxt-skew-protection] Nitro's Cloudflare entry was not bundled. Refusing to build without asset 404 protection."
|
|
264
276
|
);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-skew-protection",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.2",
|
|
5
5
|
"description": "Solve Nuxt version skews with persistent assets and instant updates.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"consola": "^3.4.2",
|
|
83
83
|
"cookie-es": "^3.1.1",
|
|
84
84
|
"nuxt-site-config": "^4.2.0",
|
|
85
|
-
"nuxtseo-shared": "^5.3.
|
|
85
|
+
"nuxtseo-shared": "^5.3.11",
|
|
86
86
|
"ofetch": "^1.5.1",
|
|
87
87
|
"pathe": "^2.0.3",
|
|
88
88
|
"pkg-types": "^2.3.1",
|