Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions packages/server-core/src/media/storageprovider/local.storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { MULTIPART_CUTOFF_SIZE } from '@etherealengine/common/src/constants/File

import { FileBrowserContentType } from '@etherealengine/engine/src/schemas/media/file-browser.schema'
import { getState } from '@etherealengine/hyperflux'
import { ChildProcess } from 'child_process'
import logger from '../../ServerLogger'
import { ServerMode, ServerState } from '../../ServerState'
import config from '../../appconfig'
Expand Down Expand Up @@ -81,9 +82,30 @@ export class LocalStorage implements StorageProviderInterface {
this._store = fsStore(this.PATH_PREFIX)

if (getState(ServerState).serverMode === ServerMode.API && !config.testEnabled) {
require('child_process').spawn('npm', ['run', 'serve-local-files'], {
cwd: process.cwd(),
stdio: 'inherit'
const child: ChildProcess = require('child_process').spawn(
'npx',
[
'http-server',
`${this.PATH_PREFIX}`,
'--ssl',
'--cert',
`${config.server.certPath}`,
'--key',
`${config.server.keyPath}`,
'--port',
'8642',
'--cors=*',
'--brotli',
'--gzip'
],
{
cwd: process.cwd(),
stdio: 'inherit',
detached: true
}
)
process.on('exit', async () => {
process.kill(-child.pid!, 'SIGINT')
})
}
this.getOriginURLs().then((result) => (this.originURLs = result))
Expand Down