mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
chore: update Docker config, dev-proxy, and HTML preview components
This commit is contained in:
1 parent
9afd5f04d5
commit
088b1d7b18
9 files changed
+53
-87
No files matched your search
@@ -49,7 +49,6 @@ async function handleProxyRequest(c: Context, db: Database): Promise<Response> {
|
||||
return c.json({ error: 'Invalid repoId' }, 400)
|
||||
}
|
||||
|
||||
const config = getDevServerConfig(db, repoId)
|
||||
const port = getDevServerPort(db)
|
||||
|
||||
if (isWebSocketUpgrade((key: string) => c.req.header(key))) {
|
||||
@@ -91,6 +90,7 @@ async function handleProxyRequest(c: Context, db: Database): Promise<Response> {
|
||||
const contentType = upstreamResponse.headers.get('content-type') ?? ''
|
||||
|
||||
if (contentType.includes('text/html')) {
|
||||
const config = getDevServerConfig(db, repoId)
|
||||
const text = await upstreamResponse.text()
|
||||
const basePath = `${DEV_PROXY_PREFIX}/${repoId}/`
|
||||
const modified = config.injectBase ? injectBaseTag(text, basePath) : rewriteDevProxyHtmlPaths(text, basePath)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const DEV_PROXY_PREFIX = '/api/dev-proxy'
|
||||
|
||||
export const HOP_BY_HOP_HEADERS = new Set([
|
||||
const HOP_BY_HOP_HEADERS = new Set([
|
||||
'connection',
|
||||
'keep-alive',
|
||||
'proxy-authenticate',
|
||||
@@ -166,8 +166,7 @@ function rewriteSrcSetCandidate(candidate: string, basePath: string): string {
|
||||
|
||||
function toDevProxyPath(path: string, basePath: string): string {
|
||||
const normalizedBasePath = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath
|
||||
const escapedBasePath = escapeRegExp(normalizedBasePath)
|
||||
if (new RegExp(`^${escapedBasePath}(?:/|$)`).test(path)) return path
|
||||
if (path === normalizedBasePath || path.startsWith(`${normalizedBasePath}/`)) return path
|
||||
return `${normalizedBasePath}${path}`
|
||||
}
|
||||
|
||||
@@ -177,6 +176,3 @@ function isBaseTagAttribute(html: string, attributeOffset: number): boolean {
|
||||
return /^<\s*base\b/i.test(html.slice(tagStart, attributeOffset))
|
||||
}
|
||||
|
||||
function escapeRegExp(value: string): string {
|
||||
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
}
|
||||
Reference in new issue
Block a user