parse-server
parse-server copied to clipboard
Node18 with localhost
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?
Thanks for opening this issue!
What specifically are you referring to and what is the benefit of that adaptation?
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.
Is that really Parse Server or Node related?
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.
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?
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.
Please feel free to open a PR