Drone with gitea login error: "unexpected EOF"

I am using gitea with drone and it doesn’t work.

When I go to /login it redirects to /login/error?message=unexpected EOF and has a 401 unauthorized error for a request to /api/user

I have no idea why it doesn’t work?

Drone debug logs:

{"level":"error","msg":"oauth: cannot exchange code: zOya3slJTpomrLWHzgUsDb1P7k3OLsqf62see2qN4nBf: unexpected EOF","time":"2022-03-21T01:13:40Z"}
{"level":"debug","msg":"cannot authenticate user: unexpected EOF","time":"2022-03-21T01:13:40Z"}

I also checked logs through my proxy server and the returned data from gitea seems to be a valid json structure:

  "access_token": "xxxxx",
  "token_type": "bearer",
  "expires_in": 3600,
  "refresh_token": "xxxxx"

I believe it was a bug with my proxy service but I have fixed it now. Strange that my browser and curl didn’t throw the same error. I guess they just ignore it.

Could you explain the issue you had with your proxy service? I do encounter the same error / issue, but I don’t really see what should be wrong with my proxy…

It was a custom proxy implementation I wrote. Using the default http reverse proxy library for the language was the fix. I can’t really help very much as you are either using apache/nginx or your own custom proxy service. Neither of which I know anything about.