diff --git a/specs/fixtures/issues/2758/pages/test-route.vue b/specs/fixtures/basic/pages/test-route.vue
similarity index 100%
rename from specs/fixtures/issues/2758/pages/test-route.vue
rename to specs/fixtures/basic/pages/test-route.vue
diff --git a/specs/fixtures/issues/2758/app.vue b/specs/fixtures/issues/2758/app.vue
deleted file mode 100644
index 6b95f8b2f..000000000
--- a/specs/fixtures/issues/2758/app.vue
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/specs/fixtures/issues/2758/nuxt.config.ts b/specs/fixtures/issues/2758/nuxt.config.ts
deleted file mode 100644
index 8a74d8086..000000000
--- a/specs/fixtures/issues/2758/nuxt.config.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-// https://nuxt.com/docs/guide/directory-structure/nuxt.config
-export default defineNuxtConfig({
- modules: ['@nuxtjs/i18n'],
- debug: false,
- i18n: {
- defaultLocale: 'en',
- strategy: 'prefix',
- rootRedirect: {
- statusCode: 418,
- path: 'test-route'
- },
- locales: [
- {
- code: 'en',
- iso: 'en-US'
- },
- {
- code: 'fr',
- iso: 'fr-FR'
- }
- ]
- }
-})
diff --git a/specs/fixtures/issues/2758/package.json b/specs/fixtures/issues/2758/package.json
deleted file mode 100644
index c151d99b2..000000000
--- a/specs/fixtures/issues/2758/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "name": "nuxt3-test-basic-usage-layers",
- "private": true,
- "type": "module",
- "scripts": {
- "dev": "nuxi dev",
- "build": "nuxt build",
- "start": "node .output/server/index.mjs"
- },
- "devDependencies": {
- "@nuxtjs/i18n": "latest",
- "nuxt": "latest"
- }
-}
diff --git a/specs/fixtures/issues/2758/pages/index.vue b/specs/fixtures/issues/2758/pages/index.vue
deleted file mode 100644
index bdd7d3e39..000000000
--- a/specs/fixtures/issues/2758/pages/index.vue
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Home
-
diff --git a/specs/issues/2758.spec.ts b/specs/issues/2758.spec.ts
deleted file mode 100644
index ad95279c2..000000000
--- a/specs/issues/2758.spec.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { test, expect, describe } from 'vitest'
-import { fileURLToPath } from 'node:url'
-import { setup, fetch, url } from '../utils'
-
-describe('#2758', async () => {
- await setup({
- rootDir: fileURLToPath(new URL(`../fixtures/issues/2758`, import.meta.url))
- })
-
- test('`statusCode` in `rootRedirect` should work with strategy "prefix"', async () => {
- const res = await fetch(url('/'))
- expect(res.status).toEqual(418)
- expect(res.headers.get('location')).toEqual('/en/test-route')
- })
-})
diff --git a/specs/routing_strategies/root_redirect.spec.ts b/specs/routing_strategies/root_redirect.spec.ts
index ea3423ac3..39bc1e0c2 100644
--- a/specs/routing_strategies/root_redirect.spec.ts
+++ b/specs/routing_strategies/root_redirect.spec.ts
@@ -1,6 +1,7 @@
import { test, expect } from 'vitest'
import { fileURLToPath } from 'node:url'
import { setup, url, fetch } from '../utils'
+import { startServerWithRuntimeConfig } from '../helper'
await setup({
rootDir: fileURLToPath(new URL(`../fixtures/basic`, import.meta.url)),
@@ -10,12 +11,41 @@ await setup({
i18n: {
strategy: 'prefix',
defaultLocale: 'en',
- rootRedirect: 'fr'
+ // configure `rootDirect` to object so it can be overwritten by `runtimeConfig`
+ rootRedirect: { path: 'about', statusCode: 302 }
}
}
})
-test('can redirect to rootRedirect option path', async () => {
- const res = await fetch('/')
- expect(res.url).toBe(url('/fr'))
+describe('rootRedirect', async () => {
+ test('can redirect to rootRedirect option path', async () => {
+ const restore = await startServerWithRuntimeConfig({
+ public: {
+ i18n: {
+ rootRedirect: 'fr'
+ }
+ }
+ })
+
+ const res = await fetch('/')
+ expect(res.url).toBe(url('/fr'))
+
+ await restore()
+ })
+
+ test('(#2758) `statusCode` in `rootRedirect` should work with strategy "prefix"', async () => {
+ const restore = await startServerWithRuntimeConfig({
+ public: {
+ i18n: {
+ rootRedirect: { statusCode: 418, path: 'test-route' }
+ }
+ }
+ })
+
+ const res = await fetch(url('/'))
+ expect(res.status).toEqual(418)
+ expect(res.headers.get('location')).toEqual('/en/test-route')
+
+ await restore()
+ })
})