Skip to content

Commit

Permalink
fix: fix webcam url with multiple moonraker instances (#1713)
Browse files Browse the repository at this point in the history
* fix: fix webcam url with multiple moonraker instances

Signed-off-by: Stefan Dej <[email protected]>

* fix: fix webcam url with multiple moonraker instances

Signed-off-by: Stefan Dej <[email protected]>

* fix: parse hostPort to int

Signed-off-by: Stefan Dej <[email protected]>

---------

Signed-off-by: Stefan Dej <[email protected]>
  • Loading branch information
meteyou authored Dec 26, 2023
1 parent 5b02b12 commit 1ad3410
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/mixins/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class BaseMixin extends Vue {
}

get hostPort(): number {
return this.$store.state.socket.port ?? 80
return parseInt(this.$store.state.socket.port ?? 80)
}

get instancesDB() {
Expand Down
8 changes: 6 additions & 2 deletions src/components/mixins/webcam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ export default class WebcamMixin extends Mixins(BaseMixin) {
// overwrite url to baseUrl, if it is an absolute URL
if (baseUrl.startsWith('http') || baseUrl.startsWith('://')) url = new URL(baseUrl)

if (baseUrl.startsWith('/webcam') && ![80, 7125, 7130].includes(this.hostPort)) {
url.port = this.hostPort.toString()
if (baseUrl.startsWith('/webcam')) {
const ports = [80]
ports.push(this.$store.state.server.config?.config?.server?.port ?? 7125)
ports.push(this.$store.state.server.config?.config?.server?.ssl_port ?? 7130)

if (!ports.includes(this.hostPort)) url.port = this.hostPort.toString()
}

return decodeURIComponent(url.toString())
Expand Down

0 comments on commit 1ad3410

Please sign in to comment.