fix(login): default apiUrl to https://usetimebook.com#4
Merged
Conversation
…ain exists) The default `apiUrl` was `https://api.usetimebook.com`, but the production deploy on DigitalOcean App Platform only has the bare `usetimebook.com` domain — both the React app and the JSON API are served from the same origin (`/api/*`). DNS for `api.usetimebook.com` returns nothing, so `verifyToken` after the browser callback always threw a bare `TypeError: fetch failed` and the CLI bailed before writing the config — making login appear to succeed (the loopback callback printed) but never persist a token. Also wrap the `fetch` call in `lib/api.ts` to surface the underlying cause (DNS, ECONNREFUSED, cert error, …) instead of the bare `fetch failed`. This would have made the misconfiguration above trivial to diagnose. Users with an already-saved bad apiUrl can re-run with `TIMEBOOK_API_URL=https://usetimebook.com timebook login` once; the corrected value will then be persisted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
apiUrlwashttps://api.usetimebook.com, but that subdomain has no DNS — DO App Platform serves both the React app and the JSON API from the bareusetimebook.com(/api/*).timebook loginsucceeds at the loopback callback, thenverifyTokenthrowsTypeError: fetch failed(DNS), the CLI bails beforewriteConfig. The user sees an opaqueerror: fetch failedand no token gets persisted.https://usetimebook.com. Also wrap thefetchcall inlib/api.tsto surface the underlying cause (DNS / ECONNREFUSED / cert / timeout) instead of the barefetch failed— would have made the misconfiguration above trivial to spot.Why
dig +short api.usetimebook.com(empty) anddoctl apps spec get(onlyusetimebook.com+www.usetimebook.comconfigured on the timebook app).https://usetimebook.com/api/auth/mereturns 401 from the backend as expected.Migration
Users with a saved bad
apiUrl(none expected, since login never persisted) can re-login once withTIMEBOOK_API_URL=https://usetimebook.com timebook login; the corrected value will then be stored.Test plan
npx @squidcode/timebook@0.1.4 loginfrom a fresh box completes login end-to-end and writes~/Library/Preferences/timebook/config.json.timebook whoamireturns the logged-in user.