Skip to content

Commit

Permalink
fix: redirect to canonical domain in production by default
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Aug 24, 2023
1 parent 67d6550 commit ccbabf6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions module/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ModuleOptions {
*
* @default false
*/
canonicalDomain: boolean
redirectToCanonicalSiteUrl?: boolean
}

const Modules = [
Expand All @@ -48,7 +48,7 @@ export default defineNuxtModule<ModuleOptions>({
return {
enabled: true,
debug: false,
canonicalDomain: false,
canonicalDomain: process.env.NODE_ENV === 'production',
splash: nuxt.options.dev,
}
},
Expand Down Expand Up @@ -92,9 +92,9 @@ export default defineNuxtModule<ModuleOptions>({
nuxt.options.experimental.headNext = true

// add redirect middleware
if (config.canonicalDomain && nuxt.options.dev === false) {
if (config.redirectToCanonicalSiteUrl) {
addServerHandler({
handler: resolve('./runtime/middleware/redirect'),
handler: resolve('./runtime/server/middleware/redirect'),
middleware: true,
})
}
Expand Down

0 comments on commit ccbabf6

Please sign in to comment.