parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Node18 with localhost

Open beiguancyc opened this issue 1 year ago • 8 comments

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?

beiguancyc avatar Dec 29 '23 00:12 beiguancyc

Thanks for opening this issue!

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

mtrezza avatar Dec 30 '23 04:12 mtrezza

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.

beiguancyc avatar Dec 31 '23 04:12 beiguancyc

Is that really Parse Server or Node related?

mtrezza avatar Jan 03 '24 00:01 mtrezza

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.

beiguancyc avatar Jan 03 '24 02:01 beiguancyc

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?

mtrezza avatar Jan 14 '24 23:01 mtrezza

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.

beiguancyc avatar Jan 16 '24 02:01 beiguancyc

Please feel free to open a PR

mtrezza avatar Feb 14 '24 20:02 mtrezza