Commit fd5e0c9
authored
fix(login): default apiUrl to https://usetimebook.com (no api. subdomain exists) (#4)
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.1 parent dfd92d5 commit fd5e0c9
2 files changed
Lines changed: 26 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
49 | 66 | | |
50 | 67 | | |
51 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | | - | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
0 commit comments