Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Run a self-hosted Forgejo served over plain HTTP (no TLS), e.g.
http://forgejo.internal:3000. - Install
fj(forgejo-cli 0.7.0) and sign in to it (fj auth login/fj auth add-token).fjstores onlyhost:portinkeys.json, with no scheme. - Confirm
fjworks:fj -H http://forgejo.internal:3000 whoamiprintscurrently signed into <user>@forgejo.internal:3000. - Open T3 Code settings (Source Control), where no project remote is in scope.
Expected behavior
The Forgejo / Gitea provider shows as authenticated, since the fj login is valid.
Actual behavior
The settings page says:
Forgejo / Gitea is not authenticated on this server. Sign in or configure credentials using the fj tool on the server host to enable change request features.
From reading the bundled server code: publicLogins(keys, remoteUrl) builds the login URL as https://${host}. It only uses http:// when a project remote URL is passed in and that remote starts with http://. With no remote (settings page), it always uses https://, so the auth check effectively runs fj --host https://forgejo.internal:3000 whoami. That fails against an HTTP-only server:
Error: error sending request for url (https://forgejo.internal:3000/api/v1/user?)
Caused by:
0: client error (Connect)
1: received corrupt message of type InvalidContentType
The same command with http:// succeeds. A project whose origin is http://... works, because the remote supplies the scheme. Only the host-level status is a false negative.
Impact
Minor bug or occasional failure
Version or commit
0.1.8-nightly.20261109.4399
Environment
Arch Linux (desktop app, nightly), forgejo-cli 0.7.0
Logs or stack traces
(see error output above)Workaround
Open a project whose origin is an http:// URL; the scheme is taken from the remote. Alternatively, serve Forgejo over HTTPS.
Suggested fix
Any of: fall back to http:// when the HTTPS probe fails with a TLS/protocol error; reuse the scheme from any known project remote on the same host; or allow configuring the scheme per host.
Activity
test(forgejo): fj login on a plain-HTTP server reads as authenticated…
test(forgejo): HTTP-only fj logins are not reported unauthenticated i…