Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

could not connect to pocketbase #97

Open
kendofriendo opened this issue Apr 30, 2024 · 8 comments
Open

could not connect to pocketbase #97

kendofriendo opened this issue Apr 30, 2024 · 8 comments

Comments

@kendofriendo
Copy link

image
image

@goniszewski
Copy link
Owner

Hello @kendofriendo! Is the root URL for Pocketbase instance available under the provided address? If so, please look at the response headers and Pocketbase logs - maybe there's some useful information for us.

@kendofriendo
Copy link
Author

I don't use the root url for anything, but I assigned it to one of my other apps and it works fine.

response headers:
image

pocketbase logs:
image

@kendofriendo
Copy link
Author

In case it's relevant, the server running caddy is separate from the computer running grimoire. I have it connected via wireguard.

@goniszewski
Copy link
Owner

Is this problem still persisting for you while using https://github.com/goniszewski/grimoire/releases/tag/v0.3.5?

@kendofriendo
Copy link
Author

Yes.

@saschatrebbin
Copy link

I have a similar, if not the same, problem - on v0.3.5.
And honestly I don't really know where to look for more information to debug this.

I deployed the app as shown in the "Quick Start" of the docs, but changed the stack so no ports were directly opened.
instead I directed my reverse proxy to make the app and the pocketbase instance available by two separate domains.
The domain of the pocketbase instance is used as the value of PUBLIC_POCKETBASE_URL.

This is the content of my .env file

# Set it if you're using external PocketBase installation (default: http://pocketbase)
# Example: PUBLIC_POCKETBASE_URL=https://grimoire.mydomain.com:8090
PUBLIC_POCKETBASE_URL=https://grimoire-pocketbase.apps.hivenet.xyz
POCKETBASE_URL=https://grimoire-pocketbase.apps.hivenet.xyz
# RECOMMENDED: Change this to your email
ROOT_ADMIN_EMAIL=admin@grimoire.localhost
# RECOMMENDED: Use a secure password. Can be later changed in PocketBase's admin panel
ROOT_ADMIN_PASSWORD=changeme
# Set this to your domain name (default: http://localhost:5173)
# Example: PUBLIC_ORIGIN=grimoire.mydomain.com
PUBLIC_ORIGIN=grimoire.apps.hivenet.xyz
# Set this to true if you're using HTTPS (default: false)
# Example: PUBLIC_HTTPS_ONLY=true
PUBLIC_HTTPS_ONLY=true
# Change to the port you want the app to listen on (default: 5173)
# Example: PORT=80
PORT=5173
# Set this to true if you want to disable public signups (default: false)
PUBLIC_SIGNUP_DISABLED=false

and this is my docker-compose.yml:

---
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
  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'
volumes:
  pb_data:
  pb_migrations:

According to the log of my grimoire container the POCKETBASE_URL is http://localhost:8090 - a value I never specified.
If I attach to the grimoire container, open a shell and view the environment variables, the correct domain is shown.

This is a screenshot of the container logs:
ksnip_20240522-211953

And here is a screenshot of the env of a shell inside the grimoire container:
ksnip_20240522-214040

If I hunted down those lines correctly, then that POCKETBASE_URL http://localhost:8090 is set here:

? 'http://localhost:8090'

And if I understand the code correctly, then that value should only be used, when the system is started in dev-mode - which it is not (also shown in the screenshot above).

But on the screenshot above the log also shows a recurring app error, which does show my specified URL.
So let's ignore that POCKETBASE_URL variable for now and let's investigate the errors in the log


And here I get stuck, because I don't understand enough about Typescript or this app.
Let's look again at the error in the log:
ksnip_20240522-211953

This path in the error looks like the URL for the grimoire app/container - and if I understand correctly, then the /internal/pb/ path is meant for proxying pocketbase connections through internal endpoints.
So why is a slash in front of that domain path?

If I open the Browser DevTools in the webapp, I get the following:
ksnip_20240522-212955

The error notification popping up shows the correct URL, but the DevTools reveal that the grimoire app URL is doubled in the sent XHR request.
I guess that is the cause of this issue, but I don't know how to proceed - I am not a dev and I'm absolutely not well versed in web app development.

@Flycro
Copy link

Flycro commented May 23, 2024

Had the same issue. The PUBLIC_ORIGIN URL was doubled in the Request to /pb/api/health.

It seems to work correctly if you add http:// or https:// to the PUBLIC_ORIGIN.

@saschatrebbin
Copy link

@Flycro thanks for that info.
changing the PUBLIC_ORIGIN URL to include https:// does make the notification banner dissapear.
But now the DevTools show a TypeError, because something is undefined.
I would ignore that, if I could use the application, but the login fails - the signup works however

ksnip_20240523-141029

The error TypeError: parts[1] is undefined is thrown on page load.
The error Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource. comes up, when I try to log in.

Here are the full contents of that second error:

Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource. [0.HKRr2abQ.js:21:12144](https://grimoire.apps.hivenet.xyz/_app/immutable/nodes/0.HKRr2abQ.js)
    m Immutable
    AsyncFunctionThrow self-hosted:857
    (Async: async)
    Br Immutable
    InterpretGeneratorResume self-hosted:1461
    AsyncFunctionNext self-hosted:852
    (Async: async)
    z Immutable
    map self-hosted:221
    Immutable 6
    InterpretGeneratorResume self-hosted:1461
    AsyncFunctionNext self-hosted:852
    (Async: async)
    tn Immutable
    <anonym> https://grimoire.apps.hivenet.xyz/:72
    (Async: promise callback)
    <anonym> https://grimoire.apps.hivenet.xyz/:71

And here is a screenshot from the pocketbase webinterface after signing up:
ksnip_20240523-141057

I'll probably just wait for a future update to set this up again from scratch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants