feat(sep): testing vclaim monitoring
This commit is contained in:
+15
-5
@@ -1,3 +1,4 @@
|
||||
import { is } from 'date-fns/locale'
|
||||
import { defineEventHandler, getCookie, getRequestHeaders, getRequestURL, readBody } from 'h3'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
@@ -5,11 +6,16 @@ export default defineEventHandler(async (event) => {
|
||||
const headers = getRequestHeaders(event)
|
||||
const url = getRequestURL(event)
|
||||
const config = useRuntimeConfig()
|
||||
|
||||
const apiOrigin = config.public.API_ORIGIN
|
||||
const pathname = url.pathname.replace(/^\/api/, '')
|
||||
|
||||
const targetUrl = apiOrigin + pathname + (url.search || '')
|
||||
const apiOrigin = config.public.API_ORIGIN
|
||||
const apiVclaim = config.public.VCLAIM
|
||||
const pathname = url.pathname.replace(/^\/api/, '')
|
||||
const isVclaim = pathname.includes('/vclaim')
|
||||
|
||||
let targetUrl = apiOrigin + pathname + (url.search || '')
|
||||
if (pathname.includes('/vclaim')) {
|
||||
targetUrl = apiVclaim + pathname.replace('/vclaim', '') + (url.search || '')
|
||||
}
|
||||
|
||||
const verificationId = headers['verification-id'] as string | undefined
|
||||
let bearer = ''
|
||||
@@ -22,7 +28,7 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
const forwardHeaders = new Headers()
|
||||
if (headers['content-type']) forwardHeaders.set('Content-Type', headers['content-type'])
|
||||
forwardHeaders.set('Authorization', `Bearer ${bearer}`)
|
||||
if (!isVclaim) forwardHeaders.set('Authorization', `Bearer ${bearer}`)
|
||||
|
||||
let body: any
|
||||
if (['POST', 'PATCH'].includes(method!)) {
|
||||
@@ -41,5 +47,9 @@ export default defineEventHandler(async (event) => {
|
||||
body,
|
||||
})
|
||||
|
||||
if (isVclaim) {
|
||||
console.log('res:', res)
|
||||
}
|
||||
|
||||
return res
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user