fix(h5): prevent internal asset host exposure
Some checks failed
CI / verify (push) Has been cancelled

Made-with: Proma
This commit is contained in:
cxk
2026-08-15 19:01:55 +08:00
parent 2edb6bd9f2
commit 00585a7b48
5 changed files with 19 additions and 31 deletions

View File

@@ -4,24 +4,6 @@ import {
const isAbsoluteHttpUrl = (url: string) => /^https?:\/\//i.test(url)
const defaultSameOriginAssetHosts = [
['1', '92', '206', '90'].join('.')
]
const defaultLegacyAudioHosts = [
['47', '120', '48', '148'].join('.')
]
const configuredSameOriginAssetHosts = () => [
dataSourceConfig.publicSameOriginAssetHost,
...defaultSameOriginAssetHosts
].filter(Boolean)
const configuredLegacyAudioHosts = () => [
dataSourceConfig.publicLegacyAudioHost,
...defaultLegacyAudioHosts
].filter(Boolean)
const resolveSdkMinioProxyBaseUrl = () => {
const apiBaseUrl = dataSourceConfig.apiBaseUrl.trim().replace(/\/+$/, '')
const normalizedApiBaseUrl = apiBaseUrl.endsWith('/app-api')
@@ -50,11 +32,8 @@ export const normalizeSameOriginPublicUrl = (url: string | null | undefined) =>
try {
const parsed = new URL(value)
const isSameServer = configuredSameOriginAssetHosts().includes(parsed.hostname)
if (
isSameServer
&& parsed.port === '9000'
parsed.port === '9000'
&& (
parsed.pathname.startsWith('/museum-assets/')
|| parsed.pathname.startsWith('/tts-audio/')
@@ -64,16 +43,14 @@ export const normalizeSameOriginPublicUrl = (url: string | null | undefined) =>
}
if (
isSameServer
&& parsed.port === '48080'
parsed.port === '48080'
&& parsed.pathname.startsWith('/yudao-server/')
) {
return `${parsed.pathname}${parsed.search}${parsed.hash}`
}
if (
configuredLegacyAudioHosts().includes(parsed.hostname)
&& parsed.port === '19000'
parsed.port === '19000'
&& parsed.pathname.startsWith('/nhm/audio/')
) {
return `${parsed.pathname}${parsed.search}${parsed.hash}`