gatsby-source-directus fails with Node 18
cdanny358 opened this issue · comments
Gatsby 5 requires Node 18, but as soon as I upgrade Node from v16.18.1 to v18.12.1, gatsby-source-directus fails with this error:
"@directus/gatsby-source-directus" threw an error while running the createSchemaCustomization lifecycle:
gatsby-source-directus: authentication failed with: connect ECONNREFUSED ::1:8055
Are credentials valid?
In Node 16 this error doesn't occur, and the project builds properly. In gatsby-config.js
, the plugin is configured like this:
{
resolve: '@directus/gatsby-source-directus',
options: {
url: 'http://localhost:8055',
auth: {
token: process.env.TOKEN
}
}
}
Update: this seems to be a problem only when Directus is hosted locally. Seems to work fine with Node 18 when Directus is hosted on a remote server. Might it have to do with http vs https?
Update 2: Found the solution. It doesn't like localhost
in the URL. Changing to the actual IP address of my computer, or even 127.0.0.1
, fixes it. Apparently Node v17 and up resolves localhost
to an IPv6 address rather than the IPv4 address of earlier Node versions.
Update 2: Found the solution. It doesn't like
localhost
in the URL. Changing to the actual IP address of my computer, or even127.0.0.1
, fixes it. Apparently Node v17 and up resolveslocalhost
to an IPv6 address rather than the IPv4 address of earlier Node versions.
Thanks for the update! Bumped into the same issue in directus-labs/examples#173 and instantly recalled your update here.