0

Everything is said, I've been trying for 5 days straight, nothing seems to do the trick, here are all the relevant codes. I just don't understand what's going on.

docker-compose.yml

version: '3'
services:
  couchdb:
    image: couchdbinit:latest
    container_name: couchdb
    ports:
      - "5984:5984"
    environment: []
    volumes:
      - logs:/opt/couchdb/data
    networks:
      - scapp-net
    restart: on-failure
  api:
    build: .
    container_name: log-api
    depends_on:
      - couchdb
    env_file:
      - ./.env
    ports:
      - "8060:8060"
    networks:
      - scapp-net
    environment:
      - NODE_ENV=dev
      - DB_URL=admin:admin@couchdb:5984
    restart: on-failure
volumes:
  logs:
    external: true
networks:
  scapp-net:
    external: true

.env file

DB_HOST=couchdb
ADMIN_NAME=admin
ADMIN_PWD=admin
DB_NAME=logs
DB_PORT=5984
PORT=8060

index.js relevant info

...
const admin_name = process.env.ADMIN_NAME
const admin_pwd = process.env.ADMIN_PWD
const db_host = process.env.DB_HOST
const db_port = process.env.DB_PORT
const db_name = process.env.DB_NAME
const db_url = `${admin_name}:${admin_pwd}@${db_host}:${db_port}/${db_name}`

const users = require('nano')(db_url);

app.put('/log', async (req, res) => {
  var response = await users.insert(log);
  console.log(response);
})
...

I keep getting this error:

log-api    | node:assert:400
log-api    |     throw err;
log-api    |     ^
log-api    | 
log-api    | AssertionError [ERR_ASSERTION]: url is not valid
log-api    |     at dbScope (/api/node_modules/nano/lib/nano.js:72:10)
log-api    |     at Object.<anonymous> (/api/index.js:27:30)
log-api    |     at Module._compile (node:internal/modules/cjs/loader:1101:14)
log-api    |     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
log-api    |     at Module.load (node:internal/modules/cjs/loader:981:32)
log-api    |     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
log-api    |     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
log-api    |     at node:internal/main/run_main_module:17:47 {
log-api    |   generatedMessage: false,
log-api    |   code: 'ERR_ASSERTION',
log-api    |   actual: false,
log-api    |   expected: true,
log-api    |   operator: '=='
log-api    | }

The network is created like this:

docker network create --driver bridge --attachable scapp-net

I'm sorry for the long post, I tried to give every info relevant to the matter. If somebody could point me towards a solution, I would be forever grateful !

  • Maybe this will give you a clue https://stackoverflow.com/questions/70014747/node-js-couchdb-and-nano-error-happened-in-your-connection – RamblinRose Nov 19 '21 at 17:04
  • @RamblinRose, thank you for taking the time to check my post, I didn't see this ticket yet, gonna give it a look – shaparder Nov 21 '21 at 16:00

0 Answers0