API redirect to back-end from nuxt

This commit is contained in:
Julien Nahum
2024-01-14 19:28:39 +01:00
parent 1cfd6ef163
commit cc12a2dd1d
3 changed files with 15 additions and 6 deletions

View File

@@ -0,0 +1,11 @@
export default defineNuxtRouteMiddleware((to, from) => {
if (process.client) return
const config = useRuntimeConfig()
if (to.fullPath.startsWith('/api')) {
const path = to.fullPath.replace('/api', '')
return navigateTo(config.public.apiBase + path, { redirectCode: 301, external: true })
}
})