Skip to content

Commit

Permalink
fix: bind api server to localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Oct 10, 2024
1 parent b2ea60f commit 12d7467
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Assign keys on Stream Deck or X-keys to playout actions.

## HTTP API

SuperConductor currently has a limited, internal, and unstable HTTP API. We plan to add a public and stable HTTP API with proper documentation in the future, but for now this internal API is available by default at `http://localhost:5500/api/internal`. The port can be changed by passing `--internal-http-api-port XXXX` as an argument to SuperConductor. This API can be disabled by passing the `--disable-internal-http-api` argument.
SuperConductor currently has a limited, internal, and unstable HTTP API. We plan to add a public and stable HTTP API with proper documentation in the future, but for now this internal API is available by default at `http://127.0.0.1:5500/api/internal`. The port can be changed by passing `--internal-http-api-port XXXX` as an argument to SuperConductor. This API can be disabled by passing the `--disable-internal-http-api` argument.

Please be aware that, because this is an internal API, it may change at any time without notice.

Expand Down
12 changes: 6 additions & 6 deletions apps/app/src/electron/SuperConductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,12 @@ export class SuperConductor {
this.analogHandler = new AnalogHandler(this.storage, this.bridgeHandler)
this.analogHandler.on('error', (e) => this.log.error(e))

if (this.disableInternalHttpApi) {
// TODO: now this becomes an API that also serves the contents of the Electron window - it should not be disabled
this.log.info(`Internal HTTP API disabled`)
} else {
this.httpAPI = new ApiServer(this.internalHttpApiPort, this.ipcServer, this.clientEventBus, this.log)
}
// TODO: this also serves the contents of the Electron window - it cannot be disabled
// if (this.disableInternalHttpApi) {
// this.log.info(`Internal HTTP API disabled`)
// } else {
this.httpAPI = new ApiServer(this.internalHttpApiPort, this.ipcServer, this.clientEventBus, this.log)
// }

this._restoreTimelines()
}
Expand Down
4 changes: 2 additions & 2 deletions apps/app/src/electron/api/ApiServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export class ApiServer {
// ---- end legacy code

this.app
.listen(port)
.then(() => log.info('Feathers server listening on localhost:' + port))
.listen(port, '127.0.0.1')
.then(() => log.info('Feathers server listening on 127.0.0.1:' + port))
.catch(log.error)
}
}
2 changes: 1 addition & 1 deletion apps/app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function createWindow(log: winston.Logger, superConductor: SuperConductor): void
// .catch((err) => log.info('An error occurred: ', err))
win.webContents.openDevTools()
}
win.loadURL(isDev ? 'http://localhost:9124' : `file://${app.getAppPath()}/dist/index.html`).catch(log.error)
win.loadURL(isDev ? 'http://127.0.0.1:9124' : `file://${app.getAppPath()}/dist/index.html`).catch(log.error)

const menuOpts = literal<GenerateMenuArgs>({
undoLabel: 'Undo',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const NewBridgeDialog: React.FC<{

return (
<Formik
initialValues={{ name: '', url: 'ws://localhost:5401' }}
initialValues={{ name: '', url: 'ws://127.0.0.1:5401' }}
validationSchema={Yup.object({
name: Yup.string().label('Rundown Name').required(),
})}
Expand Down
2 changes: 1 addition & 1 deletion apps/tsr-bridge/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const createWindow = async (): Promise<void> => {
},
})

await win.loadURL(isDev ? 'http://localhost:9125' : `file://${app.getAppPath()}/dist/index.html`)
await win.loadURL(isDev ? 'http://127.0.0.1:9125' : `file://${app.getAppPath()}/dist/index.html`)

storage.on('appData', (appData: AppData) => {
ipcClient.settings(appData.settings)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@
"ts-jest": "^29.0.5",
"typescript": "^4.9.5"
},
"prettier": "@sofie-automation/code-standard-preset/.prettierrc.json"
"prettier": "@sofie-automation/code-standard-preset/.prettierrc.json",
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}

0 comments on commit 12d7467

Please sign in to comment.