Coder Social home page Coder Social logo

Could not connect to Pocketbase about grimoire HOT 12 OPEN

v1r0x avatar v1r0x commented on June 15, 2024
Could not connect to Pocketbase

from grimoire.

Comments (12)

goniszewski avatar goniszewski commented on June 15, 2024

Hello @v1r0x!

The latest version contains multiple fixes, one related to this exact issue, please check https://github.com/goniszewski/grimoire/releases/tag/v0.3.5!

Also I'm confused why the health check url contains internal/?

A: This is Grimoire's proxy path that is proxied internally to the default Pocketbase instance. Thus, we can keep all the API calls in the app itself and not via an external connection.

I'll keep this issue open and wait for your confirmation if it's fixed for you in the latest version!

from grimoire.

v1r0x avatar v1r0x commented on June 15, 2024

Hello @goniszewski

Thanks for your fast reply. I already tried that version after it came out 😉

Edit: Is it enough to run docker-compose pull? Or should I checkout the git repo again?

Maybe I did something wrong with my setup? I'm far from an expert in docker or traefik 😀

Here's my docker-compose.yml

version: '3.7'
services:
  pocketbase:
    image: spectado/pocketbase:0.22.10
    container_name: grimoire-pocketbase
    restart: unless-stopped
    ports:
      - '8090:80'
    volumes:
      - pb_data:/pb_data
      - pb_migrations:/pb_migrations/
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:80/api/health || exit 1
      interval: 5s
      timeout: 5s
      retries: 5
    env_file: .env
    depends_on:
      - grimoire
    networks:
      - proxy
    labels:
      - "traefik.enable=true"
      # PocketBase
      - "traefik.http.routers.pocketbase.entrypoints=http"
      - "traefik.http.routers.pocketbase.rule=Host(`grimoire.mydomain.de`) && PathPrefix(`/pb/`)"
      - "traefik.http.middlewares.pocketbase.stripprefix.prefixes=/pb"
      - "traefik.http.middlewares.pocketbase-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.pocketbase.middlewares=pocketbase"
      - "traefik.http.routers.pocketbase.middlewares=pocketbase-https-redirect"
      - "traefik.http.routers.pocketbase-secure.entrypoints=https"
      - "traefik.http.routers.pocketbase-secure.rule=Host(`grimoire.mydomain.de`) && PathPrefix(`/pb/`)"
      - "traefik.http.routers.pocketbase-secure.tls=true"
      - "traefik.http.routers.pocketbase-secure.tls.certresolver=http"
      - "traefik.http.routers.pocketbase-secure.service=pocketbase"
      - "traefik.http.services.pocketbase.loadbalancer.server.port=80"
      - "traefik.docker.network=proxy"
  grimoire:
    image: goniszewski/grimoire:latest
    container_name: grimoire
    restart: unless-stopped
    env_file: .env
    volumes:
      - pb_migrations:/app/pb_migrations/
    build:
      context: .
      dockerfile: Dockerfile
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:$PORT/api/health || exit 1
      interval: 5s
      timeout: 5s
      retries: 5
    ports:
      - '$PORT:$PORT'
    networks:
      - proxy
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.grimoire.entrypoints=http"
      - "traefik.http.routers.grimoire.rule=Host(`grimoire.mydomain.de`)"
      - "traefik.http.middlewares.grimoire-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.grimoire.middlewares=grimoire-https-redirect"
      - "traefik.http.routers.grimoire-secure.entrypoints=https"
      - "traefik.http.routers.grimoire-secure.rule=Host(`grimoire.mydomain.de`)"
      - "traefik.http.routers.grimoire-secure.tls=true"
      - "traefik.http.routers.grimoire-secure.tls.certresolver=http"
      - "traefik.http.routers.grimoire-secure.service=grimoire"
      - "traefik.http.services.grimoire.loadbalancer.server.port=5173"
      - "traefik.docker.network=proxy"

networks:
  proxy:
    external: true
volumes:
  pb_data:
  pb_migrations:

and .env

# Set it if you're using external PocketBase installation (default: http://pocketbase)
PUBLIC_POCKETBASE_URL=https://grimoire.mydomain.de/pb
[email protected]
ROOT_ADMIN_PASSWORD=password
PUBLIC_ORIGIN=https://grimoire.mydomain.de
PUBLIC_HTTPS_ONLY=true
PORT=5173
PUBLIC_SIGNUP_DISABLED=true

from grimoire.

goniszewski avatar goniszewski commented on June 15, 2024

I've checked again the configuration you've provided. I do not have a single suspect, but rather a couple of ideas, so please bear with me:

  1. Did you check this configuration while using PUBLIC_POCKETBASE_URL without any value after =? It should then default to http://pocketbase
  2. Are you able to get to the app container and check related logs? The internal proxy may be to blame, and if it's true, then we can possibly have some logs to further investigate
  3. And there's the Origin, aka PUBLIC_ORIGIN env that, if not matching request's origin, can lead to CORS errors

Sorry I kept you waiting for so long!

from grimoire.

v1r0x avatar v1r0x commented on June 15, 2024

Sorry I kept you waiting for so long!

No problem at all! ❤️ Really appreciate your help!

Is there a specific log file inside the container? docker-compose logs doesn't log much. (couldn't find anything related to internal log files)

from grimoire.

v1r0x avatar v1r0x commented on June 15, 2024

I left PUBLIC_POCKETBASE_URL empty and now the initial error is gone! 🎉

BUT
When trying to add a new user and I click on "Sign up" nothing happens in the browser, but in the JS console/docker logs I get this error:

grimoire             | {
grimoire             |   invalid: true,
grimoire             |   settings: {
grimoire             |     code: 'validation_json_size_limit',
grimoire             |     message: 'The maximum allowed JSON size is 0 bytes.'
grimoire             |   }
grimoire             | }

from grimoire.

goniszewski avatar goniszewski commented on June 15, 2024

What value do you have in your .env for BODY_SIZE_LIMIT?

from grimoire.

v1r0x avatar v1r0x commented on June 15, 2024

I didn't set anything, but I tried to set it to the value from your Dockerfile. Still the same error with 0 bytes

from grimoire.

goniszewski avatar goniszewski commented on June 15, 2024

Strange. Looks more like a proxy issue that is not directly related to the app itself.

from grimoire.

v1r0x avatar v1r0x commented on June 15, 2024

Ok, thanks for the info. Then I'll dig into traefik to find my problem. Should I keep this issue open? Feel free to close it :) I'll add a new comment when I fixed my problem

from grimoire.

goniszewski avatar goniszewski commented on June 15, 2024

It's OK to left it open. I hope you will stumble upon a solution to this problem and share it with us!

from grimoire.

anarion80 avatar anarion80 commented on June 15, 2024

Something is clearly wrong here with ENV variables in general or PUBLIC_POCKETBASE_URL specifically.

After adding some debug to all places where this is used (config.ts, server.ts, lib/utils/pb.ts), this is what is seen and used at those places.

With the following .env file:

PUBLIC_POCKETBASE_URL=http://192.168.2.100:8090
[email protected]
ROOT_ADMIN_PASSWORD=changeme
PUBLIC_ORIGIN=http://localhost:5173
PUBLIC_HTTPS_ONLY=
PORT=5173
PUBLIC_SIGNUP_DISABLED=false

Env as seen from

const config = {

is:

 ~ config.ts env: {
  PUBLIC_HTTPS_ONLY: '',
  PUBLIC_ORIGIN: 'http://localhost:5173',
  PUBLIC_POCKETBASE_URL: 'http://192.168.2.100:8090',
  PUBLIC_SIGNUP_DISABLED: 'false'
}

so correctly so far.

but then immediately below (

POCKETBASE_URL:
), config object gets PUBLIC_POCKETBASE_URL differently:

🚀 ~ config.ts config: {
  HTTPS_ONLY: false,
  IS_DEV: false,
  ORIGIN: 'http://localhost:5173',
  POCKETBASE_URL: 'http://localhost:8090',
  SIGNUP_DISABLED: false
}

and therefore the app prints:

Configuration used {
  HTTPS_ONLY: false,
  IS_DEV: false,
  ORIGIN: 'http://localhost:5173',
  POCKETBASE_URL: 'http://localhost:8090',
  SIGNUP_DISABLED: false
}

and pb.ts also:

🚀 ~ pb.ts config: {
  HTTPS_ONLY: false,
  IS_DEV: false,
  ORIGIN: 'http://localhost:5173',
  POCKETBASE_URL: 'http://localhost:8090',
  SIGNUP_DISABLED: false
}
🚀 ~ pbUrl: http://localhost:5173/internal/pb

The condition should be updated to something like:

POCKETBASE_URL:
		env.PUBLIC_POCKETBASE_URL || getProcessEnvValue('PUBLIC_POCKETBASE_URL') || 'http://pocketbase',

or more elaborate to account for DEV environment. Right now the PUBLIC_POCKETBASE_URL is never used. @goniszewski

from grimoire.

v1r0x avatar v1r0x commented on June 15, 2024

Quick update from my side. I bought a new home server and tried to setup grimoire again. Now it works flawlessly! 🎉
Maybe this was related to my old arm setup instead of x86? I did not change anything, but somehow it works 🤷

from grimoire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.