typebot.io icon indicating copy to clipboard operation
typebot.io copied to clipboard

TypeError: fetch failed with Gitlab

Open ebanDev opened this issue 1 year ago • 7 comments

Hi ! I'm using the latest Typebot version with Gitlab as auth. I'm getting this issue when I'm logged in

[next-auth][error][CLIENT_FETCH_ERROR] 
https://next-auth.js.org/errors#client_fetch_error fetch failed {
  error: {
    message: 'fetch failed',
    stack: 'TypeError: fetch failed\n' +
      '    at Object.processResponse (node:internal/deps/undici/undici:6277:34)\n' +
      '    at node:internal/deps/undici/undici:6602:42\n' +
      '    at node:internal/process/task_queues:140:7\n' +
      '    at AsyncResource.runInAsyncScope (node:async_hooks:203:9)\n' +
      '    at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)\n' +
      '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)',
    name: 'TypeError'
  },
  url: 'https://editor.bot.asso.ilearned.eu/api/auth/session',
  message: 'fetch failed'
}

And it just keeps loading image

ebanDev avatar Aug 17 '22 15:08 ebanDev

Here is my env file :

version: '3.9'
services:
  typebot-db:
    image: postgres:13
    restart: always
    volumes:
      - db_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=typebot
      - POSTGRES_PASSWORD=XXXXX
  typebot-builder:
    image: baptistearno/typebot-builder:latest
    restart: always
    depends_on:
      - typebot-db
    ports:
      - '8080:3000'
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    environment:
      - DATABASE_URL=postgresql://postgres:XXXXX@typebot-db:5432/typebot
      - NEXTAUTH_URL=https://editor.bot.asso.ilearned.eu
      - NEXT_PUBLIC_VIEWER_URL=https://bot.asso.ilearned.eu
      - ENCRYPTION_SECRET=XXXX
      - GITLAB_CLIENT_ID=XXXX
      - GITLAB_CLIENT_SECRET=XXXX
      - GITLAB_BASE_URL=https://gitlab.ilearned.eu
      - GITLAB_NAME=I Learned Gitlab
  typebot-viewer:
    image: baptistearno/typebot-viewer:latest
    restart: always
    ports:
      - '8081:3000'
    # See https://docs.typebot.io/self-hosting/configuration for more configuration options
    environment:
      - DATABASE_URL=postgresql://postgres:typebot@typebot-db:5432/typebot
      - NEXT_PUBLIC_VIEWER_URL=https://bot.asso.ilearned.eu
      - ENCRYPTION_SECRET=XXXX
volumes:
  db_data:

ebanDev avatar Aug 17 '22 15:08 ebanDev

I also tried with mail-based auth and I'm still getting this 401 error code on /api/workspaces

ebanDev avatar Aug 17 '22 15:08 ebanDev

Ok so my guess is that typebot-builder container doesn't have access to internet. So the call to 'https://editor.bot.asso.ilearned.eu/api/auth/session' just fails.

You could fix the fact that the container doesn't have access to internet (for a reason I don't know)

or

You can try to set a NEXTAUTH_URL_INTERNAL to http://localhost:3000

Let me know!

baptisteArno avatar Aug 18 '22 16:08 baptisteArno

I set this internal url en var, and it works 🥳 Thanks ! :D

ebanDev avatar Aug 19 '22 10:08 ebanDev

I'll probably set it in the docker examples to avoid this kind of issue. Thank you for reporting this 👍

baptisteArno avatar Aug 19 '22 10:08 baptisteArno

Hi @baptisteArno, image

I wanted to deploy typebot on vercel with supabase attched. I have set all the variables of builder as mentioned in image according to documentation.

But still 401 error on api/workspaces "message : not authenticated".

Also set the NEXTAUTH_URL_INTERNAL to http://localhost:3000 but still not working.

Note : the api/workspaces is hitting the server as GET Request but I have searched in typebot's repo this api is implemented as PATCH, POST and DELETE request seems weird to me.

image

alihassan4198-tech avatar Sep 09 '22 10:09 alihassan4198-tech

You should not set NEXTAUTH_URL_INTERNAL in a Vercel environment! Can you fill another issue if you have a bug if it's still happening?

baptisteArno avatar Sep 09 '22 14:09 baptisteArno