From fa480e0a0a93e2a1e42b4bb806622b8b312bc442 Mon Sep 17 00:00:00 2001
From: Daniel Roe <daniel@roe.dev>
Date: Sun, 2 Mar 2025 08:32:27 +0000
Subject: [PATCH] fix(nuxt): add backwards-compatible serialisation for
 `nuxt.options.pages`

---
 packages/nuxt/src/pages/module.ts | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/packages/nuxt/src/pages/module.ts b/packages/nuxt/src/pages/module.ts
index 3e5968bc95..6700aab554 100644
--- a/packages/nuxt/src/pages/module.ts
+++ b/packages/nuxt/src/pages/module.ts
@@ -97,6 +97,12 @@ export default defineNuxtModule({
     }
     options.enabled = await isPagesEnabled()
     nuxt.options.pages = options
+    // For backwards compatibility with `@nuxtjs/i18n` and other modules that serialize `nuxt.options.pages` directly
+    // TODO: remove in a future major
+    Object.defineProperty(nuxt.options.pages, 'toString', {
+      enumerable: false,
+      get: () => () => options.enabled,
+    })
 
     if (nuxt.options.dev && options.enabled) {
       // Add plugin to check if pages are enabled without NuxtPage being instantiated