hoarder-app / hoarder

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
https://hoarder.app
GNU Affero General Public License v3.0
6.41k stars 233 forks source link

I'm encountering a "JSON Parse Error: Unexpected character: <" when attempting to log in through the iOS app. #613

Closed eplusg closed 3 days ago

eplusg commented 2 weeks ago

Describe the Bug

When logging in to the iOS app both with username&password or API key I get the following error. Logging in from the web browser works fine.

JSON Parse error: Unexpected character: <

image

Steps to Reproduce

  1. Go to the iOS App
  2. Login with username & password or API key
  3. Press Sign in

Expected Behaviour

Successful login.

Screenshots or Additional Context

The only error I see in the container is this the following. _hoarder_logs.txt

Device Details

iOS 18.1

Exact Hoarder Version

v0.18.0

MohamedBassem commented 2 weeks ago

Can you go back to the previous page and and use the connection debugging tool and share its logs?

eplusg commented 2 weeks ago

Here you go, this is all I get when I copy diagnostic result:

Running connection test ...

Using address: *redacted*

ALL GOOD
MohamedBassem commented 2 weeks ago

can you make sure you're on the newly released app version (1.6.5). I've improved the connection debugging tool since then?

eplusg commented 2 weeks ago

Ah cool, downloaded it and I see the error now. My website is exposed through a Cloudflare tunnel which requires login. The diagnostic log in the app shows this:

Running connection test ...

Using address: *redacted*

Failed to parse response as JSON: SyntaxError: JSON Parse error: Unexpected character: <

Got the following response:

<!DOCTYPE html>
<html>
  <head>
    <title>Sign in ・ Cloudflare Access</title>
    <meta charset="utf-8" />
    <meta name="robots" content="noindex" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width" />
    <article id="data"
      data-auto-redirect-to-identity="false"
      data-auto-redirect-url=""
      data-message="">
    </article>

Is it possible to use Hoarder iOS app with the website exposed through Cloudflare tunnel which requires a sign in?

kamtschatka commented 2 weeks ago

no, this is not supported. maybe you can make an exception for the /api endpoints to not require a sign in?

eplusg commented 2 weeks ago

Creating a bypass rule for the api endpoint worked, but is it safe to expose?

For anyone else facing the same issue, you can create a bypass rule by following these steps:

  1. Navigate to Zero Trust in Cloudflare.
  2. Under Access, go to Applications and click on "Add a new application".

Example for https://hoarder.yourdomain.tld, the configuration would be as follows:

  1. On the Policies page, enter a name for the policy. In the Action section, select "Bypass," and in the Configure rules section, choose the "Everyone" selector.
kamtschatka commented 3 days ago

closing this issue, as it was a config issue