Description
Your environment
SDK Version: 1.4.1
Connect Server Version: 1.7.2
OS: MacOS 11.7.9 (Big Sur - Intel) with Rancher Desktop and Docker
Node Version: v18.18.2
What happened?
Using the serverURL of http://localhost:8080
attempts to resolve via IPv6 and fails to resolve the host causing the connection to the op-connect-api
container to fail when running in local development. Using Rancher Desktop & Docker.
What did you expect to happen?
No error connecting to the op-connect-api
Docker Container and a list of vault/secrets to be returned.
Steps to reproduce
-
Create a
Secrets Automation
save the.json
and token. -
Setup OnePassword Connect server per https://developer.1password.com/docs/connect/get-started/#step-2-deploy-1password-connect-server with Rancher Desktop and Docker.
- Verify connection returns values with:
curl \ -H "Accept: application/json" \ -H "Authorization: Bearer $OP_API_TOKEN" \ http://localhost:8080/v1/vaults
-
Create a basic
test.ts
file with:import { OnePasswordConnect, Vault } from '@1password/connect'; export async function getSecrets(): Promise<Vault[]> { try { const op = OnePasswordConnect({ serverURL: 'http://localhost:8080', token: 'my-token', keepAlive: true, }); return await op.listVaults(); } catch (err) { return Promise.reject(err); } } async function main() { console.log('vaults:', await getSecrets()); } main();
-
run the file with
ts-node ./test.ts
, which results in:cause: Error: connect ECONNREFUSED ::1:8080 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) { errno: -61, code: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 8080 }
-
Changing
serverURL
tohttp://127.0.0.1:8080
and rerunning the script then works as expected; returning a list of vaults.