NuxtN
Nuxt9mo ago
4 replies
DANANZ M1

Layered Nuxt apps: How to remove routeRules defined in a base layer from an extending layer?

Okay, I'm working with layered Nuxt applications. I have app1 which is the base layer, and app2 which extends app1. In app1, I've configured several routeRules in the nuxt.config.ts. Now, in app2, I want to effectively remove or override some of the routeRules that were set in app1. How can I achieve this?

For example, if app1 has a routeRules entry like this:

// app1/nuxt.config.ts
export default defineNuxtConfig({
  routeRules: {
    '/some-path': { redirect: '/new-path' },
    // ... other rules
  }
})


In app2, I want to somehow disable or remove the /some-path redirect rule that was defined in app1. Crucially, I don't want to have to explicitly list each path I want to remove in app2 (like telling Nuxt hooks to ignore '/some-path'). I'm looking for a more automatic way for app2 to override or discard specific routeRules from app1 without manual intervention for each rule I want to discard. What's the recommended approach for this in a layered setup?
Was this page helpful?