Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to get dynamically api port for websocket #412

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BZHunt
Copy link

@BZHunt BZHunt commented Dec 1, 2022

fix #411

@@ -3,7 +3,7 @@ import {Loading} from 'quasar'
import { $t } from '@/boot/i18n'

export default ({ Vue }) => {
var socket = io(`${window.location.protocol}//${window.location.hostname}:${process.env.API_PORT}`);
var socket = io(`${window.location.protocol}//${window.location.hostname}:${window.location.port != '' ? ':'+window.location.port : ''}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I've tried your PR and it's a very useful feature. Right now you have a typo here - the colon the before port number is duplicated, if the port is non default, e.g. https://localhost::8443

Either the library or browser then strips the ::8443 and tries it on default port (443 for https).

Suggested change
var socket = io(`${window.location.protocol}//${window.location.hostname}:${window.location.port != '' ? ':'+window.location.port : ''}`);
var socket = io(`${window.location.protocol}//${window.location.hostname}${window.location.port != '' ? ':'+window.location.port : ''}`);

After this fix it looks good to me. It works even when the docker-compose port mapping is used, e.g.

  pwndoc-frontend:
    ports:
      - 8444:8443

👍 :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error of socket when API is not on default port (8443)
2 participants