opnform-host-nginx/client/middleware/api-redirect.global.js

13 lines
325 B
JavaScript
Raw Normal View History

export default defineNuxtRouteMiddleware((to) => {
if (import.meta.client) return
2024-01-14 19:28:39 +01:00
const config = useRuntimeConfig()
if (to.fullPath.startsWith("/api")) {
const path = to.fullPath.replace("/api", "")
return navigateTo(config.public.apiBase + path, {
redirectCode: 301,
external: true,
})
2024-01-14 19:28:39 +01:00
}
})