Sync Error for selfhosted server

I have been working on creating a self hosted server using cloudflare tunnels as an access point into my newtwork. I have my setup everything via docker and I am about to access the server landing page and log in via my cloudflare tunnel but when I try to "Check synchronization configurations" I keep on getting this error:

Error. Please check that URL, username, password, etc. are correct and that the sync target is accessible. The reported error was:
Unexpected token < in JSON at position 0

I have tried on the mobile and desktop apps with the same results. I have tried to use local and LTE as an access point. I created a new user to see if that would work but it still wouldn't let me connect.

@Stencoss welcome to the forum.

Could it be that Joplin is expecting a reply in JSON format but is being sent some kind of HTML error page by cloudflare or the server; a file starting with an "unexpected" < of the tag <html> rather than the expected { of JSON?

Checking the Joplin logs might reveal a bit more information. How to enable debugging | Joplin

Hey dpoulton!

I enabled the development tools and I can see the error but to be honest I am not able to understand it any better.

C:\Users\me\AppDa…n\lib\Logger.js:190 09:03:31: JoplinServerApi: curl -v -X POST -H "X-API-MIN-VERSION: 2.6.0" -H "Content-Type: application/json" -H "Content-Length: 57" --data '{"email":"myemail@gmail.com","password":"******"}' 'https://my.cloudflare.tunnel/api/sessions'
C:\Users\me\AppDa…n\lib\Logger.js:190 09:03:31: JoplinServerApi: Code: undefined
C:\Users\me\AppDa…n\lib\Logger.js:190 09:03:31: JoplinServerApi: SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at JoplinServerApi.<anonymous> (C:\Users\me\AppDa…ServerApi.js:200:42)
    at Generator.next (<anonymous>)
    at C:\Users\me\AppDa…inServerApi.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\me\AppDa…inServerApi.js:4:12)
    at loadResponseJson (C:\Users\me\AppDa…ServerApi.js:195:48)
    at JoplinServerApi.<anonymous> (C:\Users\me\AppDa…ServerApi.js:236:38)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\me\AppDa…inServerApi.js:5:58)
C:\Users\me\AppDa…n\lib\Logger.js:190 09:03:31: JoplinServerApi: Could not acquire session: undefined 
 SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at JoplinServerApi.<anonymous> (C:\Users\me\AppDa…ServerApi.js:200:42)
    at Generator.next (<anonymous>)
    at C:\Users\me\AppDa…inServerApi.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\me\AppDa…inServerApi.js:4:12)
    at loadResponseJson (C:\Users\me\AppDa…ServerApi.js:195:48)
    at JoplinServerApi.<anonymous> (C:\Users\me\AppDa…ServerApi.js:236:38)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\me\AppDa…inServerApi.js:5:58)
C:\Users\me\AppDa…n\lib\Logger.js:190 09:03:31: ShareService: Failed to run maintenance: SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at JoplinServerApi.<anonymous> (C:\Users\me\AppDa…ServerApi.js:200:42)
    at Generator.next (<anonymous>)
    at C:\Users\me\AppDa…inServerApi.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\me\AppDa…inServerApi.js:4:12)
    at loadResponseJson (C:\Users\me\AppDa…ServerApi.js:195:48)
    at JoplinServerApi.<anonymous> (C:\Users\me\AppDa…ServerApi.js:236:38)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\me\AppDa…inServerApi.js:5:58)
C:\Users\me\AppDa…n\lib\Logger.js:190 09:03:31: Synchronizer: Sync: finished: Synchronisation finished [1678201388574]
C:\Users\me\AppDa…n\lib\Logger.js:190 09:03:31: Synchronizer: Operations completed: 
C:\Users\me\AppDa…n\lib\Logger.js:190 09:03:31: Synchronizer: Total folders: 1
C:\Users\me\AppDa…n\lib\Logger.js:190 09:03:31: Synchronizer: Total notes: 5
C:\Users\me\AppDa…n\lib\Logger.js:190 09:03:31: Synchronizer: Total resources: 3
C:\Users\me\AppDa…n\lib\Logger.js:190 09:03:31: Synchronizer: There was some errors:
C:\Users\me\AppDa…n\lib\Logger.js:190 09:03:31: Synchronizer: SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at JoplinServerApi.<anonymous> (C:\Users\me\AppDa…ServerApi.js:200:42)
    at Generator.next (<anonymous>)
    at C:\Users\me\AppDa…inServerApi.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\me\me\AppDa…inServerApi.js:4:12)
    at loadResponseJson (C:\Users\me\AppDa…ServerApi.js:195:48)
    at JoplinServerApi.<anonymous> (C:\Users\me\AppDa…ServerApi.js:236:38)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\me\AppDa…inServerApi.js:5:58)

Here are the logs. I tried to edit out personal information and hopefully I got it all.

I am starting to think it is on the cloudflare side. It might be getting stuck at the authentication page for the cloudflare tunnel and not hitting the actual joplin login page. I am using OAuth for my cloudflare tunnel.

That is what I was thinking however I do not have the knowledge to help you solve this...

Anyone else?

If you open https://yourserver/joplinserverurl/ping, what does it show?

Path not found: joplinserverurl/ping
Path not found: ping

The server page still pulls up. I am guessing that is the client side web portal maybe?