generated from avior/template-web-astro
fix: idk what
Signed-off-by: Avior <github@avior.me>
This commit is contained in:
parent
e6a8738815
commit
b09a396eca
23
src/pages/api/event.ts
Normal file
23
src/pages/api/event.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import type { APIRoute } from 'astro'
|
||||
import ResponseBuilder from '../../libs/ResponseBuilder'
|
||||
|
||||
/**
|
||||
* Plausible proxy
|
||||
*/
|
||||
export const POST: APIRoute = async ({ request, clientAddress }) => {
|
||||
// const body = await request.json()
|
||||
// console.log(body, clientAddress)
|
||||
const res = await fetch('https://plausible.io/api/event', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'User-Agent': request.headers.get('User-Agent') as string,
|
||||
'X-Forwarded-For': clientAddress,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: await request.text()
|
||||
})
|
||||
return new ResponseBuilder()
|
||||
.status(res.status)
|
||||
.body(await res.text())
|
||||
.build()
|
||||
}
|
13
src/pages/js/script.js.ts
Normal file
13
src/pages/js/script.js.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import type { APIRoute } from 'astro'
|
||||
import ResponseBuilder from '../../libs/ResponseBuilder'
|
||||
|
||||
/**
|
||||
* Plausible proxy
|
||||
*/
|
||||
export const GET: APIRoute = async () => {
|
||||
const res = await fetch('https://plausible.io/js/script.outbound-links.tagged-events.js')
|
||||
return new ResponseBuilder()
|
||||
.status(200)
|
||||
.body(await res.text())
|
||||
.build()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user