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

Fix auth urls #769

Merged
merged 1 commit into from Nov 8, 2023
Merged

Fix auth urls #769

merged 1 commit into from Nov 8, 2023

Conversation

jaclarke
Copy link
Member

@jaclarke jaclarke commented Nov 8, 2023

No description provided.

Copy link
Collaborator

@scotttrinh scotttrinh left a comment

Choose a reason for hiding this comment

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

Ahh, nice catch. Without the trailing slash, the new "path" replaces the last path segment, yeah?

@jaclarke
Copy link
Member Author

jaclarke commented Nov 8, 2023

Ahh, nice catch. Without the trailing slash, the new "path" replaces the last path segment, yeah?

Yes, MiroslavPetrik caught it: #750 (comment). I think I broke it in the refactor to use URLs.

@jaclarke
Copy link
Member Author

jaclarke commented Nov 8, 2023

I'll add some tests for this once I figure out how to mock smtp.

@@ -31,7 +31,7 @@ export class Auth {
const [host, port] = connectConfig.address;
const baseUrl = `${
connectConfig.tlsSecurity === "insecure" ? "http" : "https"
}://${host}:${port}/db/${connectConfig.database}/ext/auth`;
}://${host}:${port}/db/${connectConfig.database}/ext/auth/`;
Copy link
Contributor

Choose a reason for hiding this comment

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

here I found one more problem, Next does not want to connect to host of localhost, so I have

const hostFix = host === "localhost" ? "127.0.0.1" : host;
Suggested change
}://${host}:${port}/db/${connectConfig.database}/ext/auth/`;
}://${hostFix }:${port}/db/${connectConfig.database}/ext/auth/`;

Copy link
Contributor

Choose a reason for hiding this comment

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

image

original error,
found the solution in
https://stackoverflow.com/questions/74165121/next-js-fetch-request-gives-error-typeerror-fetch-failed

Not sure if its not only local, my node version is

$ node -v
v18.18.2

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's related to this issue: nodejs/node#44731

I believe this is fixed in Node v20 (see nodejs/node#44731), but maybe there is something we can do to opt-into the same behavior in our codebase here. I'll look into that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just tested with node v20.9.0, and it still fails

Copy link
Collaborator

Choose a reason for hiding this comment

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

What is your operating system? If Node v20 is still failing in the same way, it seems like the DNS resolver is not returning 127.0.0.1 for localhost lookup which is definitely odd.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm on Windows 11. Solved it with (for now)

import dns from "node:dns";

dns.setDefaultResultOrder("ipv4first");

it also impacted the default edgedb client connection. You are right with the DNS resolver, it prioritizes the ipv6, as in the screenshot of the error we see ::1.

I don't know where to change the priority in the OS.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@MiroslavPetrik perhaps this comment might help: nodejs/node#40537 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, will save that as alternative option for developing on windows 11.

Still it seems temporary, just noticed that even the hosts file no longer uses localhost mapping (they are commented out) as that somehow interferes with ipv6 adoption, so maybe the edgedb could listen on ipv6 as well?
I don't know much about networking. Just expanding on what I just read

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's possible to make edgedb listen on ipv6 as well. There was a similar issue previously with Deno resolving localhost to the ipv6 ::1 address: #376 (comment)

@scotttrinh scotttrinh merged commit 7a76cb9 into master Nov 8, 2023
10 checks passed
@scotttrinh scotttrinh deleted the fix-auth-urls branch November 8, 2023 18:53
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.

None yet

3 participants