Self hosted domain redirect (#756)
* Integration pages from Notion * Self hosted domain redirect * Refactor root-redirect middleware and update 404 page layout - Simplified the `root-redirect.js` middleware by removing the specific route checks, allowing for a more general redirect based on the `self_hosted` feature flag. - Updated the 404 error page in `[...all].vue` by removing the unnecessary `NuxtLayout` wrapper and replacing `NuxtLink` with a custom `UButton` for navigation, enhancing the overall layout and user experience. These changes aim to streamline the redirect logic and improve the presentation of the 404 error page. * Refactor feature flag handling and update middleware - Updated the condition in `Navbar.vue` to correctly evaluate the feature flags for rendering the AI form builder link. - Removed the `feature-flags.global.js` middleware as it was no longer needed, streamlining the middleware structure. - Enhanced the `root-redirect.js` middleware to utilize `h3`'s `sendRedirect` for server-side redirection, improving the redirect logic. - Modified the `ai-form-builder.vue` page to include the new `root-redirect` middleware, ensuring proper redirection based on feature flags. These changes aim to improve the handling of feature flags and redirection logic, enhancing the overall application flow. --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
10
client/middleware/feature-flags.global.js
vendored
10
client/middleware/feature-flags.global.js
vendored
@@ -1,10 +0,0 @@
|
||||
import { useFeatureFlagsStore } from '~/stores/featureFlags'
|
||||
|
||||
export default defineNuxtRouteMiddleware(async () => {
|
||||
const featureFlagsStore = useFeatureFlagsStore()
|
||||
|
||||
// Load flags if they haven't been loaded yet
|
||||
if (!featureFlagsStore.isLoaded) {
|
||||
await featureFlagsStore.fetchFlags()
|
||||
}
|
||||
})
|
||||
21
client/middleware/root-redirect.js
vendored
Normal file
21
client/middleware/root-redirect.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { sendRedirect } from 'h3'
|
||||
|
||||
export default defineNuxtRouteMiddleware(() => {
|
||||
if (!useFeatureFlag('self_hosted')) return
|
||||
const redirectUrl = useRuntimeConfig().public.rootRedirectUrl
|
||||
|
||||
// Only run if env var is set and is a valid URL
|
||||
if (!redirectUrl || !/^https?:\/\//.test(redirectUrl)) return
|
||||
|
||||
// Server-side: use h3's sendRedirect
|
||||
if (import.meta.server) {
|
||||
|
||||
const event = useRequestEvent()
|
||||
if (event) {
|
||||
return sendRedirect(event, redirectUrl, 301)
|
||||
}
|
||||
}
|
||||
|
||||
// Client-side handling
|
||||
return navigateTo(redirectUrl, { external: true })
|
||||
})
|
||||
Reference in New Issue
Block a user