feat(frontend,API): Add PUT operations, integrate API, add first from engine
This commit is contained in:
14
legalconsenthub/server/api/[...].ts
Normal file
14
legalconsenthub/server/api/[...].ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { H3Event } from 'h3'
|
||||
import { joinURL } from 'ufo'
|
||||
|
||||
export default defineEventHandler((event: H3Event) => {
|
||||
const { serverApiBaseUrl, clientProxyBasePath } = useRuntimeConfig().public
|
||||
const escapedClientProxyBasePath = clientProxyBasePath.replace(/^\//, '\\/')
|
||||
// Use the escaped value in the regex
|
||||
const path = event.path.replace(new RegExp(`^${escapedClientProxyBasePath}`), '')
|
||||
const target = joinURL(serverApiBaseUrl, path)
|
||||
|
||||
console.log('🔀 proxying request to', target)
|
||||
|
||||
return proxyRequest(event, target)
|
||||
})
|
||||
Reference in New Issue
Block a user