Enable remote launcher catalog source
Some checks failed
Build / release (macos-latest) (push) Has been cancelled
Build / release (ubuntu-latest) (push) Has been cancelled
Build / release (windows-latest) (push) Has been cancelled
Windows Smoke Test / windows-smoke (push) Has been cancelled

This commit is contained in:
2026-05-05 22:46:03 +09:00
parent 9e8fd9e74b
commit 87c56a21d5
11 changed files with 188 additions and 38 deletions

View File

@@ -21,7 +21,7 @@
<code id="launcherCatalogPath">불러오는 중</code>
</div>
<div class="metaRow">
<span class="metaLabel">로컬 catalog URL</span>
<span class="metaLabel">앱 연결용 catalog URL</span>
<a id="localCatalogUrl" href="#" target="_blank" rel="noreferrer">불러오는 중</a>
</div>
</div>

View File

@@ -14,6 +14,7 @@ const LAUNCHER_CATALOG_PATH = path.join(PROJECT_ROOT, 'app', 'assets', 'launcher
const PUBLIC_DIR = path.join(__dirname, 'public')
const SAMPLE_DISTRIBUTION_PATH = path.join(PROJECT_ROOT, 'docs', 'sample_distribution.json')
const EXAMPLE_DISTRIBUTION_PREFIX = 'https://example.com/launcher/'
const PUBLIC_BASE_URL = normalizeText(process.env.LAUNCHER_PUBLIC_BASE_URL).replace(/\/+$/, '')
function normalizeText(value){
return typeof value === 'string' ? value.trim() : ''
@@ -45,6 +46,13 @@ function normalizeBoolean(value){
return value === true
}
function getPublicBaseUrl(){
if(PUBLIC_BASE_URL.length > 0){
return PUBLIC_BASE_URL
}
return `http://${HOST}:${PORT}`
}
function resolveSafeProjectPath(relativePath){
const resolvedPath = path.resolve(PROJECT_ROOT, relativePath)
if(!resolvedPath.startsWith(PROJECT_ROOT + path.sep) && resolvedPath !== PROJECT_ROOT){
@@ -259,6 +267,7 @@ async function start(){
app.use(express.json({ limit: '5mb' }))
app.use('/uploads', express.static(UPLOADS_DIR))
app.use('/admin/data/uploads', express.static(UPLOADS_DIR))
app.use('/admin/data/distributions', express.static(DISTRIBUTIONS_DIR))
app.get('/api/meta', async (_req, res) => {
@@ -267,7 +276,7 @@ async function start(){
port: PORT,
runtimeCatalogPath: toProjectRelativePath(RUNTIME_CATALOG_PATH),
launcherCatalogPath: toProjectRelativePath(LAUNCHER_CATALOG_PATH),
localCatalogUrl: `http://${HOST}:${PORT}/catalog.json`,
localCatalogUrl: `${getPublicBaseUrl()}/catalog.json`,
distributionsPath: toProjectRelativePath(DISTRIBUTIONS_DIR)
})
})
@@ -362,7 +371,7 @@ async function start(){
storedName: req.file.filename,
size: req.file.size,
path: relativePath,
localUrl: `http://${HOST}:${PORT}/uploads/${encodeURIComponent(req.file.filename)}`
localUrl: `${getPublicBaseUrl()}/uploads/${encodeURIComponent(req.file.filename)}`
}
})
} catch (error) {
@@ -394,7 +403,7 @@ async function start(){
ok: true,
file: {
path: relativePath,
localUrl: `http://${HOST}:${PORT}/${relativePath}`
localUrl: `${getPublicBaseUrl()}/${relativePath}`
}
})
} catch (error) {