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

Added basename config #1976

Merged
merged 3 commits into from
Apr 6, 2020
Merged

Added basename config #1976

merged 3 commits into from
Apr 6, 2020

Conversation

Legion2
Copy link
Contributor

@Legion2 Legion2 commented Apr 5, 2020

use basename in socket.io path fix #1973

The use of window.location.pathname in the socket.io path (introduced in #1937) broke some modules, because the url was not always the basename of MagicMirror. To resolve this the basename is now a configuration option which can be set in the configuration. The default value is / which results in the behavior as before #1937 was added.

use basename in socket.io path fix #1973
@MichMich
Copy link
Collaborator

MichMich commented Apr 6, 2020

Thanks for this PR. I like this approach, but I'm not sure basename is the best config name. It doesn't explain well what it does. Any other options?

@Legion2
Copy link
Contributor Author

Legion2 commented Apr 6, 2020

Other name could be basepath or rootpath.

@MichMich
Copy link
Collaborator

MichMich commented Apr 6, 2020

Let’s go for basePath. Could you update the PR?

@Legion2
Copy link
Contributor Author

Legion2 commented Apr 6, 2020

Yes I can update the PR

@MichMich MichMich merged commit 3f8363a into MagicMirrorOrg:develop Apr 6, 2020
@khassel
Copy link
Collaborator

khassel commented Apr 6, 2020

sorry, but couldn't test earlier ...

This works for the basic MM installation but still not for modules using own html sites. This should be fixed on module site, but I think we should be backward compatible for the standard use case with basePath="/".

Now the used config object is undefined in the case of MMM-Remote-Control so loading the html page end in a reference error.

So I would prefer a fix like the following in socketclient.js:

  // Private Methods
  var base = "/";
  if (typeof config !== "undefined") {
    base = config.basePath;
  }

  self.socket = io("/" + self.moduleName, {
    path: base + "socket.io"
  });

@Legion2
Copy link
Contributor Author

Legion2 commented Apr 6, 2020

I think this is a problem of the MMM-Remote-Control it should define the configuration object, or should not load the socketclient.js.

@khassel
Copy link
Collaborator

khassel commented Apr 6, 2020

yes, I know this, that was meant by

This should be fixed on module site

but this module (and may others) must be updated and you know not if or when this happens. And meanwhile all users will getting errors using these modules and have again to patch something.

This could be avoided by using / if config is undefined.

@Legion2
Copy link
Contributor Author

Legion2 commented Apr 6, 2020

@khassel Ok, can you create the PR?

@khassel
Copy link
Collaborator

khassel commented Apr 6, 2020

o.k., next evening ...

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.

3 participants