fix(stats): proxy build assets under stats path
This commit is contained in:
parent
edc7a20cea
commit
7480b97630
3 changed files with 53 additions and 42 deletions
|
|
@ -1,22 +1,8 @@
|
|||
import type { APIEvent } from "@solidjs/start/server"
|
||||
import { Resource } from "@opencode-ai/console-resource"
|
||||
import { statsProxy } from "~/lib/stats-proxy"
|
||||
|
||||
async function handler(evt: APIEvent) {
|
||||
const req = evt.request.clone()
|
||||
const url = new URL(req.url)
|
||||
const host = Resource.App.stage === "production" ? "stats.opencode.ai" : "stats.dev.opencode.ai"
|
||||
const targetUrl = `https://${host}${url.pathname}${url.search}`
|
||||
|
||||
return fetch(targetUrl, {
|
||||
method: req.method,
|
||||
headers: req.headers,
|
||||
body: req.body,
|
||||
})
|
||||
}
|
||||
|
||||
export const GET = handler
|
||||
export const POST = handler
|
||||
export const PUT = handler
|
||||
export const DELETE = handler
|
||||
export const OPTIONS = handler
|
||||
export const PATCH = handler
|
||||
export const GET = statsProxy
|
||||
export const POST = statsProxy
|
||||
export const PUT = statsProxy
|
||||
export const DELETE = statsProxy
|
||||
export const OPTIONS = statsProxy
|
||||
export const PATCH = statsProxy
|
||||
|
|
|
|||
|
|
@ -1,22 +1,8 @@
|
|||
import type { APIEvent } from "@solidjs/start/server"
|
||||
import { Resource } from "@opencode-ai/console-resource"
|
||||
import { statsProxy } from "~/lib/stats-proxy"
|
||||
|
||||
async function handler(evt: APIEvent) {
|
||||
const req = evt.request.clone()
|
||||
const url = new URL(req.url)
|
||||
const host = Resource.App.stage === "production" ? "stats.opencode.ai" : "stats.dev.opencode.ai"
|
||||
const targetUrl = `https://${host}${url.pathname}${url.search}`
|
||||
|
||||
return fetch(targetUrl, {
|
||||
method: req.method,
|
||||
headers: req.headers,
|
||||
body: req.body,
|
||||
})
|
||||
}
|
||||
|
||||
export const GET = handler
|
||||
export const POST = handler
|
||||
export const PUT = handler
|
||||
export const DELETE = handler
|
||||
export const OPTIONS = handler
|
||||
export const PATCH = handler
|
||||
export const GET = statsProxy
|
||||
export const POST = statsProxy
|
||||
export const PUT = statsProxy
|
||||
export const DELETE = statsProxy
|
||||
export const OPTIONS = statsProxy
|
||||
export const PATCH = statsProxy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue