Skip to content

Beautiful Open-Source Form Builder

Merge branch 'main' of https://github.com/JhumanJ/OpnForm

Julien Nahumfaf65430a9ff
diff --cc client/server/api/feature-flags.get.js
index 691c05f67,000000000..1f108f3f2
mode 100644,000000..100644
--- a/client/server/api/feature-flags.get.js
+++ b/client/server/api/feature-flags.get.js
@@@ -1,33 -1,0 +1,33 @@@
+// Cached server API route for feature flags
- export default defineCachedEventHandler(async (event) => {
++export default defineCachedEventHandler(async () => {
+ const config = useRuntimeConfig()
+
+ // Call Laravel API directly with proper headers
+ const apiBase = config.privateApiBase || config.public.apiBase
+
+ try {
+ const response = await $fetch('/content/feature-flags', {
+ baseURL: apiBase,
+ headers: {
+ 'accept': 'application/json',
+ ...(config.apiSecret && { 'x-api-secret': config.apiSecret })
+ }
+ })
+
+ return response
+ } catch (error) {
+ console.error('Failed to fetch feature flags from Laravel API:', error)
+ // Return empty object as fallback to prevent breaking the app
+ return {}
+ }
+}, {
+ maxAge: 10 * 60, // 10 minutes cache
+ name: 'feature-flags',
+ getKey: (event) => {
+ // Include timestamp in cache key for cache-busting when refreshing
+ const url = new URL(event.node.req.url || '', 'http://localhost')
+ const timestamp = url.searchParams.get('t')
+ return timestamp ? `global:${timestamp}` : 'global'
+ },
+ swr: true // Serve stale while revalidating in background
+})