From 4b30eb68019af7b98f62318f66019bdfb9c9b9f8 Mon Sep 17 00:00:00 2001 From: John Hildenbiddle Date: Thu, 21 Dec 2023 13:45:59 -0600 Subject: [PATCH] =?UTF-8?q?Fix=20for=20Vercal=20=E2=80=9Cunsupported=20mod?= =?UTF-8?q?ules=E2=80=9D=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- middleware.js | 4 +--- rewriterules.config.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 rewriterules.config.js diff --git a/middleware.js b/middleware.js index 6a3150b6d..6f612f936 100644 --- a/middleware.js +++ b/middleware.js @@ -1,6 +1,4 @@ -import serverConfigs from './server.configs.js'; - -const { rewriteRules } = serverConfigs.dev; +import rewriteRules from './rewriterules.config.js'; // Exports // ============================================================================= diff --git a/rewriterules.config.js b/rewriterules.config.js new file mode 100644 index 000000000..cef981231 --- /dev/null +++ b/rewriterules.config.js @@ -0,0 +1,23 @@ +export default [ + // Replace CDN URLs with local paths + { + match: /https?.*\/CHANGELOG.md/g, + replace: '/CHANGELOG.md', + }, + { + // CDN versioned default + // Ex1: //cdn.com/package-name + // Ex2: http://cdn.com/package-name@1.0.0 + // Ex3: https://cdn.com/package-name@latest + match: /(?:https?:)*\/\/.*cdn.*docsify[@\d.latest]*(?=["'])/g, + replace: '/lib/docsify.min.js', + }, + { + // CDN paths to local paths + // Ex1: //cdn.com/package-name/path/file.js => /path/file.js + // Ex2: http://cdn.com/package-name@1.0.0/dist/file.js => /dist/file.js + // Ex3: https://cdn.com/package-name@latest/dist/file.js => /dist/file.js + match: /(?:https?:)*\/\/.*cdn.*docsify[@\d.latest]*\/(?:lib\/)/g, + replace: '/lib/', + }, +];