diff --git a/packages/nuxt/src/core/plugins/import-protection.ts b/packages/nuxt/src/core/plugins/import-protection.ts index 1c11d946dbf..6237a579c6e 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) {