@bleedingdev/modern-js-app-tools 3.2.0-ultramodern.68 → 3.2.0-ultramodern.70
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/cjs/plugins/deploy/platforms/cloudflare.js +2 -1
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +18 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +2 -1
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +18 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +2 -1
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +18 -0
- package/package.json +11 -11
|
@@ -187,7 +187,8 @@ const createCloudflarePreset = ({ appContext, modernConfig })=>{
|
|
|
187
187
|
main: WORKER_ENTRY,
|
|
188
188
|
compatibility_date: getCompatibilityDate(),
|
|
189
189
|
compatibility_flags: [
|
|
190
|
-
'nodejs_compat'
|
|
190
|
+
'nodejs_compat',
|
|
191
|
+
'global_fetch_strictly_public'
|
|
191
192
|
],
|
|
192
193
|
assets: {
|
|
193
194
|
directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
|
|
@@ -67,6 +67,20 @@ function normalizeRoutePath(pathname) {
|
|
|
67
67
|
if ('/' === pathname) return pathname;
|
|
68
68
|
return pathname.replace(/\/+$/u, '');
|
|
69
69
|
}
|
|
70
|
+
function getPathExtension(pathname) {
|
|
71
|
+
const lastSegment = pathname.split('/').pop() || '';
|
|
72
|
+
const dotIndex = lastSegment.lastIndexOf('.');
|
|
73
|
+
if (dotIndex <= 0 || dotIndex === lastSegment.length - 1) return '';
|
|
74
|
+
return lastSegment.slice(dotIndex).toLowerCase();
|
|
75
|
+
}
|
|
76
|
+
function isAssetLikePathname(pathname) {
|
|
77
|
+
const extension = getPathExtension(pathname);
|
|
78
|
+
return '' !== extension && '.html' !== extension && '.htm' !== extension;
|
|
79
|
+
}
|
|
80
|
+
function routeMatchesExactly(route, pathname) {
|
|
81
|
+
if ('string' != typeof route?.urlPath) return false;
|
|
82
|
+
return normalizeRoutePath(route.urlPath) === normalizeRoutePath(pathname);
|
|
83
|
+
}
|
|
70
84
|
function routeMatches(route, pathname) {
|
|
71
85
|
if ('string' != typeof route.urlPath) return false;
|
|
72
86
|
const routePath = normalizeRoutePath(route.urlPath);
|
|
@@ -389,6 +403,10 @@ export default {
|
|
|
389
403
|
const bffResponse = await dispatchBffRequest(request, env);
|
|
390
404
|
if (bffResponse) return withCorsHeaders(bffResponse);
|
|
391
405
|
const route = findRoute(request);
|
|
406
|
+
const { pathname } = new URL(request.url);
|
|
407
|
+
if (isAssetLikePathname(pathname) && !routeMatchesExactly(route, pathname)) return withCorsHeaders(new Response('Not found', {
|
|
408
|
+
status: 404
|
|
409
|
+
}));
|
|
392
410
|
if (route?.worker) return withCorsHeaders(await dispatchRouteWorker(route, request, env, ctx));
|
|
393
411
|
const htmlResponse = await fetchRouteHtml(route, request, env);
|
|
394
412
|
if (htmlResponse) return htmlResponse;
|
|
@@ -149,7 +149,8 @@ const createCloudflarePreset = ({ appContext, modernConfig })=>{
|
|
|
149
149
|
main: WORKER_ENTRY,
|
|
150
150
|
compatibility_date: getCompatibilityDate(),
|
|
151
151
|
compatibility_flags: [
|
|
152
|
-
'nodejs_compat'
|
|
152
|
+
'nodejs_compat',
|
|
153
|
+
'global_fetch_strictly_public'
|
|
153
154
|
],
|
|
154
155
|
assets: {
|
|
155
156
|
directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
|
|
@@ -67,6 +67,20 @@ function normalizeRoutePath(pathname) {
|
|
|
67
67
|
if ('/' === pathname) return pathname;
|
|
68
68
|
return pathname.replace(/\/+$/u, '');
|
|
69
69
|
}
|
|
70
|
+
function getPathExtension(pathname) {
|
|
71
|
+
const lastSegment = pathname.split('/').pop() || '';
|
|
72
|
+
const dotIndex = lastSegment.lastIndexOf('.');
|
|
73
|
+
if (dotIndex <= 0 || dotIndex === lastSegment.length - 1) return '';
|
|
74
|
+
return lastSegment.slice(dotIndex).toLowerCase();
|
|
75
|
+
}
|
|
76
|
+
function isAssetLikePathname(pathname) {
|
|
77
|
+
const extension = getPathExtension(pathname);
|
|
78
|
+
return '' !== extension && '.html' !== extension && '.htm' !== extension;
|
|
79
|
+
}
|
|
80
|
+
function routeMatchesExactly(route, pathname) {
|
|
81
|
+
if ('string' != typeof route?.urlPath) return false;
|
|
82
|
+
return normalizeRoutePath(route.urlPath) === normalizeRoutePath(pathname);
|
|
83
|
+
}
|
|
70
84
|
function routeMatches(route, pathname) {
|
|
71
85
|
if ('string' != typeof route.urlPath) return false;
|
|
72
86
|
const routePath = normalizeRoutePath(route.urlPath);
|
|
@@ -389,6 +403,10 @@ export default {
|
|
|
389
403
|
const bffResponse = await dispatchBffRequest(request, env);
|
|
390
404
|
if (bffResponse) return withCorsHeaders(bffResponse);
|
|
391
405
|
const route = findRoute(request);
|
|
406
|
+
const { pathname } = new URL(request.url);
|
|
407
|
+
if (isAssetLikePathname(pathname) && !routeMatchesExactly(route, pathname)) return withCorsHeaders(new Response('Not found', {
|
|
408
|
+
status: 404
|
|
409
|
+
}));
|
|
392
410
|
if (route?.worker) return withCorsHeaders(await dispatchRouteWorker(route, request, env, ctx));
|
|
393
411
|
const htmlResponse = await fetchRouteHtml(route, request, env);
|
|
394
412
|
if (htmlResponse) return htmlResponse;
|
|
@@ -150,7 +150,8 @@ const createCloudflarePreset = ({ appContext, modernConfig })=>{
|
|
|
150
150
|
main: WORKER_ENTRY,
|
|
151
151
|
compatibility_date: getCompatibilityDate(),
|
|
152
152
|
compatibility_flags: [
|
|
153
|
-
'nodejs_compat'
|
|
153
|
+
'nodejs_compat',
|
|
154
|
+
'global_fetch_strictly_public'
|
|
154
155
|
],
|
|
155
156
|
assets: {
|
|
156
157
|
directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
|
|
@@ -67,6 +67,20 @@ function normalizeRoutePath(pathname) {
|
|
|
67
67
|
if ('/' === pathname) return pathname;
|
|
68
68
|
return pathname.replace(/\/+$/u, '');
|
|
69
69
|
}
|
|
70
|
+
function getPathExtension(pathname) {
|
|
71
|
+
const lastSegment = pathname.split('/').pop() || '';
|
|
72
|
+
const dotIndex = lastSegment.lastIndexOf('.');
|
|
73
|
+
if (dotIndex <= 0 || dotIndex === lastSegment.length - 1) return '';
|
|
74
|
+
return lastSegment.slice(dotIndex).toLowerCase();
|
|
75
|
+
}
|
|
76
|
+
function isAssetLikePathname(pathname) {
|
|
77
|
+
const extension = getPathExtension(pathname);
|
|
78
|
+
return '' !== extension && '.html' !== extension && '.htm' !== extension;
|
|
79
|
+
}
|
|
80
|
+
function routeMatchesExactly(route, pathname) {
|
|
81
|
+
if ('string' != typeof route?.urlPath) return false;
|
|
82
|
+
return normalizeRoutePath(route.urlPath) === normalizeRoutePath(pathname);
|
|
83
|
+
}
|
|
70
84
|
function routeMatches(route, pathname) {
|
|
71
85
|
if ('string' != typeof route.urlPath) return false;
|
|
72
86
|
const routePath = normalizeRoutePath(route.urlPath);
|
|
@@ -389,6 +403,10 @@ export default {
|
|
|
389
403
|
const bffResponse = await dispatchBffRequest(request, env);
|
|
390
404
|
if (bffResponse) return withCorsHeaders(bffResponse);
|
|
391
405
|
const route = findRoute(request);
|
|
406
|
+
const { pathname } = new URL(request.url);
|
|
407
|
+
if (isAssetLikePathname(pathname) && !routeMatchesExactly(route, pathname)) return withCorsHeaders(new Response('Not found', {
|
|
408
|
+
status: 404
|
|
409
|
+
}));
|
|
392
410
|
if (route?.worker) return withCorsHeaders(await dispatchRouteWorker(route, request, env, ctx));
|
|
393
411
|
const htmlResponse = await fetchRouteHtml(route, request, env);
|
|
394
412
|
if (htmlResponse) return htmlResponse;
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.2.0-ultramodern.
|
|
20
|
+
"version": "3.2.0-ultramodern.70",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"exports": {
|
|
@@ -99,16 +99,16 @@
|
|
|
99
99
|
"ndepe": "^0.1.13",
|
|
100
100
|
"pkg-types": "^2.3.1",
|
|
101
101
|
"std-env": "4.1.0",
|
|
102
|
-
"@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.2.0-ultramodern.
|
|
103
|
-
"@modern-js/plugin
|
|
104
|
-
"@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.2.0-ultramodern.
|
|
105
|
-
"@modern-js/server": "npm:@bleedingdev/modern-js-server@3.2.0-ultramodern.
|
|
106
|
-
"@modern-js/
|
|
107
|
-
"@modern-js/server
|
|
108
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.
|
|
109
|
-
"@modern-js/
|
|
110
|
-
"@modern-js/
|
|
111
|
-
"@modern-js/
|
|
102
|
+
"@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.2.0-ultramodern.70",
|
|
103
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.70",
|
|
104
|
+
"@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.2.0-ultramodern.70",
|
|
105
|
+
"@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.2.0-ultramodern.70",
|
|
106
|
+
"@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.2.0-ultramodern.70",
|
|
107
|
+
"@modern-js/server": "npm:@bleedingdev/modern-js-server@3.2.0-ultramodern.70",
|
|
108
|
+
"@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.2.0-ultramodern.70",
|
|
109
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.70",
|
|
110
|
+
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.70",
|
|
111
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.70"
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
114
|
"@rslib/core": "0.21.5",
|