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

core: properly handle localhost uris on Electron #10590

Merged
merged 1 commit into from
Jan 12, 2022

Conversation

paul-marechal
Copy link
Member

When running Electron window.location is not a standard HTTP(S) URL,
so we cannot use it to determine the host where the backend is running.

Resolve the remote host to localhost when running Electron.

Closes #10574

How to test

  1. Start the electron example app
  2. Print a link to localhost in the terminal, e.g. localhost:3000
  3. Ctrl+click on the link
  4. The link should open in an external browser.

Review checklist

Reminder for reviewers

When running Electron `window.location` is not a standard HTTP(S) URL,
so we cannot use it to determine the host where the backend is running.

Resolve the remote host to `localhost` when running Electron.
@vince-fugnitto vince-fugnitto added the electron issues related to the electron target label Jan 4, 2022
@colin-grant-work
Copy link
Contributor

This looks pretty reasonable to me. It leaves a little bit more room for later customization than #10574.

Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

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

This looks good to me. @AlexandraBuzila, does this address your concerns with the current handling of localhost?

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

I confirmed that the changes work well 👍

On master, using echo localhost:3000 in the terminal and attempting to click the link results in the following error:

cat: standard output: Bad file descriptor
sh: echo: I/O error

The same use-case works well with this change (the link is opened in an external browser).

@AlexandraBuzila
Copy link
Contributor

This looks good to me. @AlexandraBuzila, does this address your concerns with the current handling of localhost?

Thank you for the changes, they work for me!

@paul-marechal paul-marechal merged commit fb74ef0 into master Jan 12, 2022
@paul-marechal paul-marechal deleted the mp/localhost-links branch January 12, 2022 18:49
@vince-fugnitto vince-fugnitto added this to the 1.22.0 milestone Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron issues related to the electron target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants