From 247deacc2bd2e901db6193517c5cd02aaa69cce0 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 8 Jun 2022 20:51:38 +0100 Subject: [PATCH] fix(nuxt): relax server import protections (#5355) Co-authored-by: pooya parsa --- packages/nuxt/src/core/plugins/import-protection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nuxt/src/core/plugins/import-protection.ts b/packages/nuxt/src/core/plugins/import-protection.ts index 1c11d946db..6237a579c6 100644 --- a/packages/nuxt/src/core/plugins/import-protection.ts +++ b/packages/nuxt/src/core/plugins/import-protection.ts @@ -20,7 +20,7 @@ export const vueAppPatterns = (nuxt: Nuxt) => [ [new RegExp(`^${escapeRE(m)}$`), 'Importing directly from module entry points is not allowed.']), ...[/(^|node_modules\/)@nuxt\/kit/, /^nitropack/] .map(i => [i, 'This module cannot be imported in the Vue part of your app.']), - [new RegExp(escapeRE(resolve(nuxt.options.srcDir, (nuxt.options.dir as any).server || 'server'))), 'Importing from server middleware is not allowed in the Vue part of your app.'] + [new RegExp(escapeRE(resolve(nuxt.options.srcDir, (nuxt.options.dir as any).server || 'server')) + '\\/(api|routes|middleware|plugins)\\/'), 'Importing from server is not allowed in the Vue part of your app.'] ] as ImportProtectionOptions['patterns'] export const ImportProtectionPlugin = createUnplugin(function (options: ImportProtectionOptions) {