Skip Navigation
Lemmy Support @lemmy.ml tootbrute @lemmy.ca

Initial Docker setup error: SyntaxError: JSON.parse unexpected end of data

I have been struggling with getting a docker setup of lemmy running on amr64 server and I almost got it going.

docker compose up -d

  • Then i go to my domain.com/setup and try to make my first admin user.
  • When I click Sign Up, I get an error:

SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data

Server:

VPS, 2 cpu cores, 12 GB ram Ubuntu OS Caddy as reverse proxy, but I left nginx in the docker-compose file

Logs

docker-compose.yml https://pastebin.com/XHUbMKJL

docker compose logs https://pastebin.com/TzZyK1kN

Caddyfile https://pastebin.com/CjJWthSe

6
6 comments
  • SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data

    This is an error you are getting in your web browser with lemmy-ui? Do you know how to use the console of Firefox or Chrome to look at what API call that error is coming from?

    Caddy as reverse proxy, but I left nginx

    Could be related to your problem... as lemmy-ui doesn't seem to be talking to the API to get JSON responses. I suggest looking at your proxy logs at the instant you press submit on the form.

    • OK thanks for the tip.

      Firefox, F12, debugger

      API error: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
      e https://tw.arkadi.one/static/js/client.js:2
          p https://tw.arkadi.one/static/js/client.js:2
          C https://tw.arkadi.one/static/js/client.js:2
          w https://tw.arkadi.one/static/js/client.js:2
          y https://tw.arkadi.one/static/js/client.js:2
          s https://tw.arkadi.one/static/js/client.js:2
      

      Caddy log

      {"level":"error","ts":1692060935.893172,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"49.159.84.13","remote_port":"41462","client_ip":"IP_REDACTED","proto":"HTTP/2.0","method":"POST","host":"tw.arkadi.one","uri":"/api/v3/user/register","headers":{"Referer":["https://tw.arkadi.one/setup"],"Cookie":[],"Content-Type":["application/json"],"Accept-Encoding":["gzip, deflate, br"],"Dnt":["1"],"Te":["trailers"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/116.0"],"Origin":["https://tw.arkadi.one"],"Sec-Fetch-Dest":["empty"],"Content-Length":["112"],"Accept-Language":["en-CA,en-US;q=0.7,en;q=0.3"],"Sec-Fetch-Mode":["cors"],"Sec-Fetch-Site":["same-origin"],"Accept":["*/*"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"tw.arkadi.one"}},"bytes_read":0,"user_id":"","duration":0.002207562,"size":0,"status":502,"resp_headers":{"Server":["Caddy"],"Alt-Svc":["h3=\":443\"; ma=2592000"]}}

      I don't see anything wrong here though it says it is an error. Hmm.

      EDIT: Ok one thing that could be wrong is it says the protcol is HTTP/2.0.

      I noticed on the troubleshooting page of Lemmy it says

      Make sure that websocket is working correctly, by checking the browser console for errors. In nginx, the following headers are important for this:

      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      

      So, I am now searching if I can get Caddy to serve HTTP/1.1 for websockets?

      • These aren't really what you are looking for in the Firefox console. They tell you the line of code with the error, but not which page has the JSON missing itself.

        I notice your server says Lemmy 0.18.0 - the current is 0.18.4 - any reason you are attempting an older version?

        /api/v3/user/register

        those are the kind of paths you are looking for that can't be reached and your proxy likely isn't forwarding correctly to the lemmy_server Rust app.

You've viewed 6 comments.