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

Node 17+ localhost resolution #21

Closed
ganigeorgiev opened this issue Aug 7, 2022 · 3 comments
Closed

Node 17+ localhost resolution #21

ganigeorgiev opened this issue Aug 7, 2022 · 3 comments

Comments

@ganigeorgiev
Copy link
Member

ganigeorgiev commented Aug 7, 2022

This is related to pocketbase/pocketbase#258 and pocketbase/pocketbase#272.

In short, when the PocketBase backend is started with the default localhost:8090 address, the go dns resolver will return first the IPv4 address (aka. 127.0.0.1), and then, if available, the IPv6 version (aka. [::1]).

Node17+ for some reason favors the opposite (IPv6 first, then IPv4) and therefore when you initialize the SDK client using the localhost address, eg:

const client = new PocketBase("http://localhost:8090")

it could actually resolve to the IPv6 version ([::1]) and will result in connection failure (because the PocketBase backend will be binded only to the IPv4 version).

To fix this, you could simply provide explicitly the IPv4 localhost address, aka:

const client = new PocketBase("http://127.0.0.1:8090")

Since there isn't much we can do from the backend side (unless we bind to both ipv4 and ipv6 or to 0.0.0.0), we'll have to improve the SDK error reporting to make it more clear what could be the reason behind the connection failure.

@ganigeorgiev ganigeorgiev changed the title Node 17+ localhost issue Node 17+ localhost resolution Aug 7, 2022
@ollema
Copy link
Contributor

ollema commented Aug 7, 2022

maybe it would make sense to update the documentation/API previews as well so that they use 127.0.0.1 instead of localhost?
Screenshot from 2022-08-07 09-50-01

@ganigeorgiev
Copy link
Member Author

With the latest v0.4.0 release, the original fetch error is properly stored and now will be visible in the stack trace.

Additionally, all localhost occurrences are replaced with 127.0.0.1 in both the site documentation and in the Admin UI.

@kerns
Copy link

kerns commented Jun 27, 2024

Does this not complicate auth via providers that require localhost in the callback ? (e.g. Microsoft) 🤔

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

No branches or pull requests

3 participants