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

Node18 with localhost #8854

Open
beiguancyc opened this issue Dec 29, 2023 · 8 comments
Open

Node18 with localhost #8854

beiguancyc opened this issue Dec 29, 2023 · 8 comments
Labels
type:question Support or code-level question

Comments

@beiguancyc
Copy link

Feature / Enhancement Description

Node18 has altered the resolution for localhost, now defaulting to IPV6. However, examining the internal code, I noticed that many parts are still using 127.0.0.1. Can we adapt to this modification made by Node18?

Copy link

Thanks for opening this issue!

@mtrezza mtrezza added the type:question Support or code-level question label Dec 30, 2023
@mtrezza
Copy link
Member

mtrezza commented Dec 30, 2023

What specifically are you referring to and what is the benefit of that adaptation?

@beiguancyc
Copy link
Author

What specifically are you referring to and what is the benefit of that adaptation?

In Node.js 16, it's not necessary to include serverUrl in the configuration file, but in Node.js 18, it's mandatory to specify serverUrl: 127.0.0.1+port+mount in the configuration file; otherwise, it will result in an error. I'm not sure how many other changes might be needed.

@mtrezza
Copy link
Member

mtrezza commented Jan 3, 2024

Is that really Parse Server or Node related?

@beiguancyc
Copy link
Author

My configuration file is similar to the following, and it works without any issues in Node 16.
{
"appId" : "aaaa",
"masterKey" : "aaaa",
"databaseURI" : "mongodb://user:pass@localhost:27010/db",
"port" : "1234",
"mountPath" : "/a",
}

However, in versions below Node 18, modifications are required for it to function properly. The MongoDB address needs to be changed from 'localhost' to '127.0.0.1', and a 'serverUrl' needs to be added.
If 'serverUrl' is not added, an error will occur, but it can still be used normally.

@mtrezza
Copy link
Member

mtrezza commented Jan 14, 2024

The MongoDB address needs to be changed from 'localhost' to '127.0.0.1'

That may be because Node.js tries to resolve IPv6 first, but you are running in an IPv4 environment, so you need to set 127.0.0.1; you can change the resolver behavior in Node.js; still I wonder whether this isn't just a Node.js config issue; what behavior would you expect from Parse Server?

a 'serverUrl' needs to be added

Not sure about that, did you look into the source code to find out what that is?

@beiguancyc
Copy link
Author

When I was looking through the source code, I noticed that 'localhost' is used in many places, and I'm not sure if upgrading to Node 18 will have any impact.
Regarding the error "a 'serverUrl' needs to be added," it is just a warning and does not affect the program's operation, though fixing it would certainly be more user-friendly.

@mtrezza
Copy link
Member

mtrezza commented Feb 14, 2024

Please feel free to open a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

2 participants