@softistx/alxia-react-router 0.0.0-stage → 0.83.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (609) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2085 -2
  3. package/dist/api-keys/api-keys.d.ts +93 -0
  4. package/dist/api-keys/api-keys.d.ts.map +1 -0
  5. package/dist/api-keys/index.d.ts +9 -0
  6. package/dist/api-keys/index.d.ts.map +1 -0
  7. package/dist/api-keys/index.js +66 -0
  8. package/dist/api-keys/index.js.map +10 -0
  9. package/dist/assets.d.ts +14 -0
  10. package/dist/assets.d.ts.map +1 -0
  11. package/dist/chunks/index-0786n4qe.js +25 -0
  12. package/dist/chunks/index-0786n4qe.js.map +10 -0
  13. package/dist/chunks/index-1nw5yeek.js +169 -0
  14. package/dist/chunks/index-1nw5yeek.js.map +11 -0
  15. package/dist/chunks/index-59vhfj6n.js +10 -0
  16. package/dist/chunks/index-59vhfj6n.js.map +10 -0
  17. package/dist/chunks/index-5gqcpyyg.js +34 -0
  18. package/dist/chunks/index-5gqcpyyg.js.map +10 -0
  19. package/dist/chunks/index-6jf7zpxz.js +119 -0
  20. package/dist/chunks/index-6jf7zpxz.js.map +11 -0
  21. package/dist/chunks/index-8as4j8m3.js +340 -0
  22. package/dist/chunks/index-8as4j8m3.js.map +16 -0
  23. package/dist/chunks/index-9xv2a8et.js +108 -0
  24. package/dist/chunks/index-9xv2a8et.js.map +11 -0
  25. package/dist/chunks/index-ajtvyq35.js +16 -0
  26. package/dist/chunks/index-ajtvyq35.js.map +10 -0
  27. package/dist/chunks/index-c55hxgr5.js +124 -0
  28. package/dist/chunks/index-c55hxgr5.js.map +14 -0
  29. package/dist/chunks/index-d42p3mdp.js +19 -0
  30. package/dist/chunks/index-d42p3mdp.js.map +10 -0
  31. package/dist/chunks/index-gac44rs5.js +42 -0
  32. package/dist/chunks/index-gac44rs5.js.map +11 -0
  33. package/dist/chunks/index-j4ktpcke.js +62 -0
  34. package/dist/chunks/index-j4ktpcke.js.map +10 -0
  35. package/dist/chunks/index-mscfme4r.js +12 -0
  36. package/dist/chunks/index-mscfme4r.js.map +10 -0
  37. package/dist/chunks/index-pghmb2dm.js +30 -0
  38. package/dist/chunks/index-pghmb2dm.js.map +10 -0
  39. package/dist/chunks/index-rfr02vg4.js +40 -0
  40. package/dist/chunks/index-rfr02vg4.js.map +10 -0
  41. package/dist/chunks/index-sfhshxqz.js +31 -0
  42. package/dist/chunks/index-sfhshxqz.js.map +10 -0
  43. package/dist/chunks/index-skwypsjz.js +357 -0
  44. package/dist/chunks/index-skwypsjz.js.map +12 -0
  45. package/dist/chunks/index-sxh06ged.js +118 -0
  46. package/dist/chunks/index-sxh06ged.js.map +11 -0
  47. package/dist/chunks/index-t2ph23wk.js +96 -0
  48. package/dist/chunks/index-t2ph23wk.js.map +13 -0
  49. package/dist/chunks/index-thyabr5n.js +19 -0
  50. package/dist/chunks/index-thyabr5n.js.map +10 -0
  51. package/dist/chunks/index-tx36swjx.js +134 -0
  52. package/dist/chunks/index-tx36swjx.js.map +11 -0
  53. package/dist/chunks/index-v2z5k640.js +54 -0
  54. package/dist/chunks/index-v2z5k640.js.map +11 -0
  55. package/dist/chunks/index-vr82typq.js +23 -0
  56. package/dist/chunks/index-vr82typq.js.map +11 -0
  57. package/dist/chunks/index-whj6h5eg.js +9 -0
  58. package/dist/chunks/index-whj6h5eg.js.map +10 -0
  59. package/dist/chunks/index-wyypkfdv.js +130 -0
  60. package/dist/chunks/index-wyypkfdv.js.map +13 -0
  61. package/dist/chunks/index-xd5aqy3g.js +90 -0
  62. package/dist/chunks/index-xd5aqy3g.js.map +10 -0
  63. package/dist/chunks/index-zdbqzcjp.js +97 -0
  64. package/dist/chunks/index-zdbqzcjp.js.map +12 -0
  65. package/dist/chunks/index-zyg8amjc.js +23 -0
  66. package/dist/chunks/index-zyg8amjc.js.map +10 -0
  67. package/dist/cli/index.d.ts +3 -0
  68. package/dist/cli/index.d.ts.map +1 -0
  69. package/dist/cli/index.js +215 -0
  70. package/dist/cli/index.js.map +13 -0
  71. package/dist/cli/main.d.ts +13 -0
  72. package/dist/cli/main.d.ts.map +1 -0
  73. package/dist/cli/reveal.d.ts +18 -0
  74. package/dist/cli/reveal.d.ts.map +1 -0
  75. package/dist/cli/template.d.ts +8 -0
  76. package/dist/cli/template.d.ts.map +1 -0
  77. package/dist/context.d.ts +104 -0
  78. package/dist/context.d.ts.map +1 -0
  79. package/dist/document/index.d.ts +11 -0
  80. package/dist/document/index.d.ts.map +1 -0
  81. package/dist/document/index.js +19 -0
  82. package/dist/document/index.js.map +9 -0
  83. package/dist/document/inline-script.d.ts +27 -0
  84. package/dist/document/inline-script.d.ts.map +1 -0
  85. package/dist/document/language-store.d.ts +8 -0
  86. package/dist/document/language-store.d.ts.map +1 -0
  87. package/dist/document/nonce.d.ts +34 -0
  88. package/dist/document/nonce.d.ts.map +1 -0
  89. package/dist/document/page-language.d.ts +39 -0
  90. package/dist/document/page-language.d.ts.map +1 -0
  91. package/dist/document/text-direction.d.ts +10 -0
  92. package/dist/document/text-direction.d.ts.map +1 -0
  93. package/dist/entry/abort.d.ts +21 -0
  94. package/dist/entry/abort.d.ts.map +1 -0
  95. package/dist/entry/create-entry.d.ts +41 -0
  96. package/dist/entry/create-entry.d.ts.map +1 -0
  97. package/dist/entry/index.d.ts +8 -0
  98. package/dist/entry/index.d.ts.map +1 -0
  99. package/dist/entry/index.js +154 -0
  100. package/dist/entry/index.js.map +13 -0
  101. package/dist/entry/root-data.d.ts +27 -0
  102. package/dist/entry/root-data.d.ts.map +1 -0
  103. package/dist/entry/whole-page.d.ts +10 -0
  104. package/dist/entry/whole-page.d.ts.map +1 -0
  105. package/dist/errors/api-error.d.ts +117 -0
  106. package/dist/errors/api-error.d.ts.map +1 -0
  107. package/dist/errors/api-errors.d.ts +122 -0
  108. package/dist/errors/api-errors.d.ts.map +1 -0
  109. package/dist/errors/call-failure.d.ts +45 -0
  110. package/dist/errors/call-failure.d.ts.map +1 -0
  111. package/dist/errors/catalogue-check.d.ts +24 -0
  112. package/dist/errors/catalogue-check.d.ts.map +1 -0
  113. package/dist/errors/catalogue-read.d.ts +33 -0
  114. package/dist/errors/catalogue-read.d.ts.map +1 -0
  115. package/dist/errors/catalogue.d.ts +59 -0
  116. package/dist/errors/catalogue.d.ts.map +1 -0
  117. package/dist/errors/code-resolver.d.ts +44 -0
  118. package/dist/errors/code-resolver.d.ts.map +1 -0
  119. package/dist/errors/cross-site.d.ts +8 -0
  120. package/dist/errors/cross-site.d.ts.map +1 -0
  121. package/dist/errors/describe-refusal.d.ts +6 -0
  122. package/dist/errors/describe-refusal.d.ts.map +1 -0
  123. package/dist/errors/describe.d.ts +3 -0
  124. package/dist/errors/describe.d.ts.map +1 -0
  125. package/dist/errors/fetcher-result.d.ts +33 -0
  126. package/dist/errors/fetcher-result.d.ts.map +1 -0
  127. package/dist/errors/field-placement.d.ts +12 -0
  128. package/dist/errors/field-placement.d.ts.map +1 -0
  129. package/dist/errors/form-errors.d.ts +8 -0
  130. package/dist/errors/form-errors.d.ts.map +1 -0
  131. package/dist/errors/form-refusal.d.ts +25 -0
  132. package/dist/errors/form-refusal.d.ts.map +1 -0
  133. package/dist/errors/index.d.ts +21 -0
  134. package/dist/errors/index.d.ts.map +1 -0
  135. package/dist/errors/index.js +588 -0
  136. package/dist/errors/index.js.map +26 -0
  137. package/dist/errors/json-actions.d.ts +38 -0
  138. package/dist/errors/json-actions.d.ts.map +1 -0
  139. package/dist/errors/log.d.ts +8 -0
  140. package/dist/errors/log.d.ts.map +1 -0
  141. package/dist/errors/message-values.d.ts +11 -0
  142. package/dist/errors/message-values.d.ts.map +1 -0
  143. package/dist/errors/messages.d.ts +63 -0
  144. package/dist/errors/messages.d.ts.map +1 -0
  145. package/dist/errors/page-path.d.ts +9 -0
  146. package/dist/errors/page-path.d.ts.map +1 -0
  147. package/dist/errors/problem-error.d.ts +50 -0
  148. package/dist/errors/problem-error.d.ts.map +1 -0
  149. package/dist/errors/provider.d.ts +20 -0
  150. package/dist/errors/provider.d.ts.map +1 -0
  151. package/dist/errors/request-id.d.ts +5 -0
  152. package/dist/errors/request-id.d.ts.map +1 -0
  153. package/dist/errors/route-error.d.ts +33 -0
  154. package/dist/errors/route-error.d.ts.map +1 -0
  155. package/dist/errors/route-refusal.d.ts +20 -0
  156. package/dist/errors/route-refusal.d.ts.map +1 -0
  157. package/dist/errors/same-site.d.ts +49 -0
  158. package/dist/errors/same-site.d.ts.map +1 -0
  159. package/dist/errors/section-action.d.ts +46 -0
  160. package/dist/errors/section-action.d.ts.map +1 -0
  161. package/dist/errors/standard-schema.d.ts +34 -0
  162. package/dist/errors/standard-schema.d.ts.map +1 -0
  163. package/dist/errors/submit-form.d.ts +16 -0
  164. package/dist/errors/submit-form.d.ts.map +1 -0
  165. package/dist/errors/upstream-headers.d.ts +18 -0
  166. package/dist/errors/upstream-headers.d.ts.map +1 -0
  167. package/dist/errors/use-json-fetcher.d.ts +18 -0
  168. package/dist/errors/use-json-fetcher.d.ts.map +1 -0
  169. package/dist/fetcher/auth-refusal.d.ts +29 -0
  170. package/dist/fetcher/auth-refusal.d.ts.map +1 -0
  171. package/dist/fetcher/index.d.ts +20 -0
  172. package/dist/fetcher/index.d.ts.map +1 -0
  173. package/dist/fetcher/index.js +392 -0
  174. package/dist/fetcher/index.js.map +21 -0
  175. package/dist/fetcher/section-form.d.ts +24 -0
  176. package/dist/fetcher/section-form.d.ts.map +1 -0
  177. package/dist/fetcher/section-reload.d.ts +17 -0
  178. package/dist/fetcher/section-reload.d.ts.map +1 -0
  179. package/dist/fetcher/section-save.d.ts +29 -0
  180. package/dist/fetcher/section-save.d.ts.map +1 -0
  181. package/dist/fetcher/use-debounced-fetcher.d.ts +57 -0
  182. package/dist/fetcher/use-debounced-fetcher.d.ts.map +1 -0
  183. package/dist/fetcher/use-fetcher-answer.d.ts +16 -0
  184. package/dist/fetcher/use-fetcher-answer.d.ts.map +1 -0
  185. package/dist/fetcher/use-fetcher-done.d.ts +15 -0
  186. package/dist/fetcher/use-fetcher-done.d.ts.map +1 -0
  187. package/dist/fetcher/use-fetcher-promise.d.ts +48 -0
  188. package/dist/fetcher/use-fetcher-promise.d.ts.map +1 -0
  189. package/dist/fetcher/use-form-refusal.d.ts +20 -0
  190. package/dist/fetcher/use-form-refusal.d.ts.map +1 -0
  191. package/dist/fetcher/use-revalidate-on-focus.d.ts +20 -0
  192. package/dist/fetcher/use-revalidate-on-focus.d.ts.map +1 -0
  193. package/dist/fetcher/use-row-save.d.ts +32 -0
  194. package/dist/fetcher/use-row-save.d.ts.map +1 -0
  195. package/dist/fetcher/use-section-save.d.ts +46 -0
  196. package/dist/fetcher/use-section-save.d.ts.map +1 -0
  197. package/dist/fetcher/use-visible-interval.d.ts +24 -0
  198. package/dist/fetcher/use-visible-interval.d.ts.map +1 -0
  199. package/dist/fetcher/use-visible-revalidation.d.ts +10 -0
  200. package/dist/fetcher/use-visible-revalidation.d.ts.map +1 -0
  201. package/dist/health.d.ts +21 -0
  202. package/dist/health.d.ts.map +1 -0
  203. package/dist/help/check/check.d.ts +35 -0
  204. package/dist/help/check/check.d.ts.map +1 -0
  205. package/dist/help/check/index.d.ts +8 -0
  206. package/dist/help/check/index.d.ts.map +1 -0
  207. package/dist/help/check/index.js +17 -0
  208. package/dist/help/check/index.js.map +9 -0
  209. package/dist/help/check/routes.d.ts +22 -0
  210. package/dist/help/check/routes.d.ts.map +1 -0
  211. package/dist/help/guide.d.ts +33 -0
  212. package/dist/help/guide.d.ts.map +1 -0
  213. package/dist/help/index.d.ts +16 -0
  214. package/dist/help/index.d.ts.map +1 -0
  215. package/dist/help/index.js +192 -0
  216. package/dist/help/index.js.map +14 -0
  217. package/dist/help/load.d.ts +39 -0
  218. package/dist/help/load.d.ts.map +1 -0
  219. package/dist/help/panel.d.ts +69 -0
  220. package/dist/help/panel.d.ts.map +1 -0
  221. package/dist/help/parse-flow.d.ts +27 -0
  222. package/dist/help/parse-flow.d.ts.map +1 -0
  223. package/dist/help/react.d.ts +12 -0
  224. package/dist/help/react.d.ts.map +1 -0
  225. package/dist/help/resolve.d.ts +24 -0
  226. package/dist/help/resolve.d.ts.map +1 -0
  227. package/dist/help/types.d.ts +50 -0
  228. package/dist/help/types.d.ts.map +1 -0
  229. package/dist/help/yaml.d.ts +18 -0
  230. package/dist/help/yaml.d.ts.map +1 -0
  231. package/dist/index.d.ts +7 -0
  232. package/dist/index.d.ts.map +1 -0
  233. package/dist/index.js +197 -0
  234. package/dist/index.js.map +14 -0
  235. package/dist/link/index.d.ts +7 -0
  236. package/dist/link/index.d.ts.map +1 -0
  237. package/dist/link/index.js +16 -0
  238. package/dist/link/index.js.map +10 -0
  239. package/dist/link/router-link.d.ts +27 -0
  240. package/dist/link/router-link.d.ts.map +1 -0
  241. package/dist/lists/connection-page.d.ts +50 -0
  242. package/dist/lists/connection-page.d.ts.map +1 -0
  243. package/dist/lists/index.d.ts +13 -0
  244. package/dist/lists/index.d.ts.map +1 -0
  245. package/dist/lists/index.js +205 -0
  246. package/dist/lists/index.js.map +15 -0
  247. package/dist/lists/newest-first.d.ts +5 -0
  248. package/dist/lists/newest-first.d.ts.map +1 -0
  249. package/dist/lists/nodes-of.d.ts +21 -0
  250. package/dist/lists/nodes-of.d.ts.map +1 -0
  251. package/dist/lists/or-failed.d.ts +19 -0
  252. package/dist/lists/or-failed.d.ts.map +1 -0
  253. package/dist/lists/use-paged-rows.d.ts +40 -0
  254. package/dist/lists/use-paged-rows.d.ts.map +1 -0
  255. package/dist/lists/use-same-route-loading.d.ts +8 -0
  256. package/dist/lists/use-same-route-loading.d.ts.map +1 -0
  257. package/dist/lists/use-search-change.d.ts +20 -0
  258. package/dist/lists/use-search-change.d.ts.map +1 -0
  259. package/dist/mcp/index.d.ts +8 -0
  260. package/dist/mcp/index.d.ts.map +1 -0
  261. package/dist/mcp/index.js +105 -0
  262. package/dist/mcp/index.js.map +11 -0
  263. package/dist/mcp/mcp-relay.d.ts +58 -0
  264. package/dist/mcp/mcp-relay.d.ts.map +1 -0
  265. package/dist/mcp/relay.d.ts +38 -0
  266. package/dist/mcp/relay.d.ts.map +1 -0
  267. package/dist/media/client/error.d.ts +29 -0
  268. package/dist/media/client/error.d.ts.map +1 -0
  269. package/dist/media/client/index.d.ts +8 -0
  270. package/dist/media/client/index.d.ts.map +1 -0
  271. package/dist/media/client/index.js +133 -0
  272. package/dist/media/client/index.js.map +11 -0
  273. package/dist/media/client/upload.d.ts +32 -0
  274. package/dist/media/client/upload.d.ts.map +1 -0
  275. package/dist/media/forward.d.ts +14 -0
  276. package/dist/media/forward.d.ts.map +1 -0
  277. package/dist/media/headers.d.ts +11 -0
  278. package/dist/media/headers.d.ts.map +1 -0
  279. package/dist/media/index.d.ts +9 -0
  280. package/dist/media/index.d.ts.map +1 -0
  281. package/dist/media/index.js +396 -0
  282. package/dist/media/index.js.map +16 -0
  283. package/dist/media/options.d.ts +114 -0
  284. package/dist/media/options.d.ts.map +1 -0
  285. package/dist/media/path.d.ts +12 -0
  286. package/dist/media/path.d.ts.map +1 -0
  287. package/dist/media/read.d.ts +11 -0
  288. package/dist/media/read.d.ts.map +1 -0
  289. package/dist/media/refusal.d.ts +11 -0
  290. package/dist/media/refusal.d.ts.map +1 -0
  291. package/dist/media/respond.d.ts +8 -0
  292. package/dist/media/respond.d.ts.map +1 -0
  293. package/dist/media/write.d.ts +13 -0
  294. package/dist/media/write.d.ts.map +1 -0
  295. package/dist/navigation/index.d.ts +9 -0
  296. package/dist/navigation/index.d.ts.map +1 -0
  297. package/dist/navigation/index.js +48 -0
  298. package/dist/navigation/index.js.map +11 -0
  299. package/dist/navigation/use-focus-on-navigate.d.ts +16 -0
  300. package/dist/navigation/use-focus-on-navigate.d.ts.map +1 -0
  301. package/dist/navigation/use-route-transition.d.ts +19 -0
  302. package/dist/navigation/use-route-transition.d.ts.map +1 -0
  303. package/dist/nonce.d.ts +16 -0
  304. package/dist/nonce.d.ts.map +1 -0
  305. package/dist/oauth/answer.d.ts +33 -0
  306. package/dist/oauth/answer.d.ts.map +1 -0
  307. package/dist/oauth/binding.d.ts +43 -0
  308. package/dist/oauth/binding.d.ts.map +1 -0
  309. package/dist/oauth/consent.d.ts +134 -0
  310. package/dist/oauth/consent.d.ts.map +1 -0
  311. package/dist/oauth/grants.d.ts +88 -0
  312. package/dist/oauth/grants.d.ts.map +1 -0
  313. package/dist/oauth/index.d.ts +16 -0
  314. package/dist/oauth/index.d.ts.map +1 -0
  315. package/dist/oauth/index.js +207 -0
  316. package/dist/oauth/index.js.map +12 -0
  317. package/dist/oauth/model.d.ts +13 -0
  318. package/dist/oauth/model.d.ts.map +1 -0
  319. package/dist/oauth/react/index.d.ts +7 -0
  320. package/dist/oauth/react/index.d.ts.map +1 -0
  321. package/dist/oauth/react/index.js +99 -0
  322. package/dist/oauth/react/index.js.map +10 -0
  323. package/dist/oauth/react/use-consent.d.ts +52 -0
  324. package/dist/oauth/react/use-consent.d.ts.map +1 -0
  325. package/dist/oidc/dpop.d.ts +80 -0
  326. package/dist/oidc/dpop.d.ts.map +1 -0
  327. package/dist/oidc/errors.d.ts +16 -0
  328. package/dist/oidc/errors.d.ts.map +1 -0
  329. package/dist/oidc/flow.d.ts +59 -0
  330. package/dist/oidc/flow.d.ts.map +1 -0
  331. package/dist/oidc/index.d.ts +11 -0
  332. package/dist/oidc/index.d.ts.map +1 -0
  333. package/dist/oidc/index.js +742 -0
  334. package/dist/oidc/index.js.map +15 -0
  335. package/dist/oidc/oidc.d.ts +132 -0
  336. package/dist/oidc/oidc.d.ts.map +1 -0
  337. package/dist/oidc/revoke.d.ts +28 -0
  338. package/dist/oidc/revoke.d.ts.map +1 -0
  339. package/dist/oidc/seal.d.ts +20 -0
  340. package/dist/oidc/seal.d.ts.map +1 -0
  341. package/dist/pwa/build/build-worker.d.ts +41 -0
  342. package/dist/pwa/build/build-worker.d.ts.map +1 -0
  343. package/dist/pwa/build/index.d.ts +9 -0
  344. package/dist/pwa/build/index.d.ts.map +1 -0
  345. package/dist/pwa/build/index.js +9 -0
  346. package/dist/pwa/build/index.js.map +9 -0
  347. package/dist/pwa/build/precache.d.ts +17 -0
  348. package/dist/pwa/build/precache.d.ts.map +1 -0
  349. package/dist/pwa/index.d.ts +16 -0
  350. package/dist/pwa/index.d.ts.map +1 -0
  351. package/dist/pwa/index.js +110 -0
  352. package/dist/pwa/index.js.map +12 -0
  353. package/dist/pwa/model/caching.d.ts +46 -0
  354. package/dist/pwa/model/caching.d.ts.map +1 -0
  355. package/dist/pwa/model/clear-app-caches.d.ts +9 -0
  356. package/dist/pwa/model/clear-app-caches.d.ts.map +1 -0
  357. package/dist/pwa/model/font-precache.d.ts +15 -0
  358. package/dist/pwa/model/font-precache.d.ts.map +1 -0
  359. package/dist/pwa/model/manifest.d.ts +80 -0
  360. package/dist/pwa/model/manifest.d.ts.map +1 -0
  361. package/dist/pwa/model/precache-list.d.ts +40 -0
  362. package/dist/pwa/model/precache-list.d.ts.map +1 -0
  363. package/dist/pwa/model/registration.d.ts +39 -0
  364. package/dist/pwa/model/registration.d.ts.map +1 -0
  365. package/dist/pwa/model/start-service-worker.d.ts +24 -0
  366. package/dist/pwa/model/start-service-worker.d.ts.map +1 -0
  367. package/dist/pwa/model/storable.d.ts +8 -0
  368. package/dist/pwa/model/storable.d.ts.map +1 -0
  369. package/dist/pwa/model/theme-color.d.ts +20 -0
  370. package/dist/pwa/model/theme-color.d.ts.map +1 -0
  371. package/dist/pwa/model/update-notice.d.ts +38 -0
  372. package/dist/pwa/model/update-notice.d.ts.map +1 -0
  373. package/dist/pwa/model/worker-contract.d.ts +61 -0
  374. package/dist/pwa/model/worker-contract.d.ts.map +1 -0
  375. package/dist/pwa/react/index.d.ts +9 -0
  376. package/dist/pwa/react/index.d.ts.map +1 -0
  377. package/dist/pwa/react/index.js +75 -0
  378. package/dist/pwa/react/index.js.map +13 -0
  379. package/dist/pwa/react/use-online.d.ts +6 -0
  380. package/dist/pwa/react/use-online.d.ts.map +1 -0
  381. package/dist/pwa/react/use-service-worker.d.ts +33 -0
  382. package/dist/pwa/react/use-service-worker.d.ts.map +1 -0
  383. package/dist/pwa/react/use-update-notice.d.ts +14 -0
  384. package/dist/pwa/react/use-update-notice.d.ts.map +1 -0
  385. package/dist/pwa/server/index.d.ts +7 -0
  386. package/dist/pwa/server/index.d.ts.map +1 -0
  387. package/dist/pwa/server/index.js +18 -0
  388. package/dist/pwa/server/index.js.map +10 -0
  389. package/dist/pwa/server/no-cache.d.ts +22 -0
  390. package/dist/pwa/server/no-cache.d.ts.map +1 -0
  391. package/dist/pwa/worker/index.d.ts +9 -0
  392. package/dist/pwa/worker/index.d.ts.map +1 -0
  393. package/dist/pwa/worker/index.js +144 -0
  394. package/dist/pwa/worker/index.js.map +12 -0
  395. package/dist/pwa/worker/injected.d.ts +15 -0
  396. package/dist/pwa/worker/injected.d.ts.map +1 -0
  397. package/dist/pwa/worker/plan.d.ts +65 -0
  398. package/dist/pwa/worker/plan.d.ts.map +1 -0
  399. package/dist/pwa/worker/scope.d.ts +18 -0
  400. package/dist/pwa/worker/scope.d.ts.map +1 -0
  401. package/dist/pwa/worker/start-worker.d.ts +17 -0
  402. package/dist/pwa/worker/start-worker.d.ts.map +1 -0
  403. package/dist/react-router.d.ts +68 -0
  404. package/dist/react-router.d.ts.map +1 -0
  405. package/dist/server.d.ts +127 -0
  406. package/dist/server.d.ts.map +1 -0
  407. package/dist/session/codes.d.ts +9 -0
  408. package/dist/session/codes.d.ts.map +1 -0
  409. package/dist/session/cookies.d.ts +128 -0
  410. package/dist/session/cookies.d.ts.map +1 -0
  411. package/dist/session/flow-types.d.ts +235 -0
  412. package/dist/session/flow-types.d.ts.map +1 -0
  413. package/dist/session/guard.d.ts +10 -0
  414. package/dist/session/guard.d.ts.map +1 -0
  415. package/dist/session/index.d.ts +22 -0
  416. package/dist/session/index.d.ts.map +1 -0
  417. package/dist/session/index.js +1090 -0
  418. package/dist/session/index.js.map +27 -0
  419. package/dist/session/land.d.ts +28 -0
  420. package/dist/session/land.d.ts.map +1 -0
  421. package/dist/session/link-json.d.ts +22 -0
  422. package/dist/session/link-json.d.ts.map +1 -0
  423. package/dist/session/link-land.d.ts +20 -0
  424. package/dist/session/link-land.d.ts.map +1 -0
  425. package/dist/session/link-token.d.ts +24 -0
  426. package/dist/session/link-token.d.ts.map +1 -0
  427. package/dist/session/link-types.d.ts +142 -0
  428. package/dist/session/link-types.d.ts.map +1 -0
  429. package/dist/session/links.d.ts +14 -0
  430. package/dist/session/links.d.ts.map +1 -0
  431. package/dist/session/model/index.d.ts +8 -0
  432. package/dist/session/model/index.d.ts.map +1 -0
  433. package/dist/session/model/index.js +35 -0
  434. package/dist/session/model/index.js.map +9 -0
  435. package/dist/session/model/link-post.d.ts +35 -0
  436. package/dist/session/model/link-post.d.ts.map +1 -0
  437. package/dist/session/model/paths.d.ts +24 -0
  438. package/dist/session/model/paths.d.ts.map +1 -0
  439. package/dist/session/model/safe-next.d.ts +15 -0
  440. package/dist/session/model/safe-next.d.ts.map +1 -0
  441. package/dist/session/model/second-factor.d.ts +16 -0
  442. package/dist/session/model/second-factor.d.ts.map +1 -0
  443. package/dist/session/model/site-path.d.ts +10 -0
  444. package/dist/session/model/site-path.d.ts.map +1 -0
  445. package/dist/session/model/step-up-answers.d.ts +45 -0
  446. package/dist/session/model/step-up-answers.d.ts.map +1 -0
  447. package/dist/session/model/step-up-props.d.ts +22 -0
  448. package/dist/session/model/step-up-props.d.ts.map +1 -0
  449. package/dist/session/model/step-up.d.ts +48 -0
  450. package/dist/session/model/step-up.d.ts.map +1 -0
  451. package/dist/session/react/index.d.ts +13 -0
  452. package/dist/session/react/index.d.ts.map +1 -0
  453. package/dist/session/react/index.js +196 -0
  454. package/dist/session/react/index.js.map +14 -0
  455. package/dist/session/react/step-up/answers.d.ts +9 -0
  456. package/dist/session/react/step-up/answers.d.ts.map +1 -0
  457. package/dist/session/react/step-up/dialog-props.d.ts +27 -0
  458. package/dist/session/react/step-up/dialog-props.d.ts.map +1 -0
  459. package/dist/session/react/step-up/index.d.ts +7 -0
  460. package/dist/session/react/step-up/index.d.ts.map +1 -0
  461. package/dist/session/react/step-up/pending-runs.d.ts +21 -0
  462. package/dist/session/react/step-up/pending-runs.d.ts.map +1 -0
  463. package/dist/session/react/step-up/phase.d.ts +8 -0
  464. package/dist/session/react/step-up/phase.d.ts.map +1 -0
  465. package/dist/session/react/step-up/use-step-up-replay.d.ts +59 -0
  466. package/dist/session/react/step-up/use-step-up-replay.d.ts.map +1 -0
  467. package/dist/session/react/step-up/use-step-up-runner.d.ts +70 -0
  468. package/dist/session/react/step-up/use-step-up-runner.d.ts.map +1 -0
  469. package/dist/session/react/step-up/use-step-up.d.ts +51 -0
  470. package/dist/session/react/step-up/use-step-up.d.ts.map +1 -0
  471. package/dist/session/react/use-code-field.d.ts +37 -0
  472. package/dist/session/react/use-code-field.d.ts.map +1 -0
  473. package/dist/session/react/use-link-fragment.d.ts +22 -0
  474. package/dist/session/react/use-link-fragment.d.ts.map +1 -0
  475. package/dist/session/react/use-link-param.d.ts +26 -0
  476. package/dist/session/react/use-link-param.d.ts.map +1 -0
  477. package/dist/session/react/use-link-post.d.ts +39 -0
  478. package/dist/session/react/use-link-post.d.ts.map +1 -0
  479. package/dist/session/react/use-sign-out.d.ts +46 -0
  480. package/dist/session/react/use-sign-out.d.ts.map +1 -0
  481. package/dist/session/second-factor.d.ts +22 -0
  482. package/dist/session/second-factor.d.ts.map +1 -0
  483. package/dist/session/serialize.d.ts +42 -0
  484. package/dist/session/serialize.d.ts.map +1 -0
  485. package/dist/session/sign-in.d.ts +19 -0
  486. package/dist/session/sign-in.d.ts.map +1 -0
  487. package/dist/session/signed.d.ts +44 -0
  488. package/dist/session/signed.d.ts.map +1 -0
  489. package/dist/session/social-flow.d.ts +22 -0
  490. package/dist/session/social-flow.d.ts.map +1 -0
  491. package/dist/session/social-land.d.ts +31 -0
  492. package/dist/session/social-land.d.ts.map +1 -0
  493. package/dist/session/social-types.d.ts +136 -0
  494. package/dist/session/social-types.d.ts.map +1 -0
  495. package/dist/session/social.d.ts +32 -0
  496. package/dist/session/social.d.ts.map +1 -0
  497. package/dist/session/step-up-codes.d.ts +9 -0
  498. package/dist/session/step-up-codes.d.ts.map +1 -0
  499. package/dist/session/step-up-signed-out.d.ts +21 -0
  500. package/dist/session/step-up-signed-out.d.ts.map +1 -0
  501. package/dist/session/step-up-types.d.ts +127 -0
  502. package/dist/session/step-up-types.d.ts.map +1 -0
  503. package/dist/session/step-up.d.ts +17 -0
  504. package/dist/session/step-up.d.ts.map +1 -0
  505. package/dist/session/step.d.ts +22 -0
  506. package/dist/session/step.d.ts.map +1 -0
  507. package/dist/session/throttle.d.ts +73 -0
  508. package/dist/session/throttle.d.ts.map +1 -0
  509. package/dist/session/timed-wait.d.ts +4 -0
  510. package/dist/session/timed-wait.d.ts.map +1 -0
  511. package/dist/session/viewer.d.ts +34 -0
  512. package/dist/session/viewer.d.ts.map +1 -0
  513. package/dist/subscription/documents.d.ts +3 -0
  514. package/dist/subscription/documents.d.ts.map +1 -0
  515. package/dist/subscription/index.d.ts +7 -0
  516. package/dist/subscription/index.d.ts.map +1 -0
  517. package/dist/subscription/index.js +359 -0
  518. package/dist/subscription/index.js.map +14 -0
  519. package/dist/subscription/proxy.d.ts +54 -0
  520. package/dist/subscription/proxy.d.ts.map +1 -0
  521. package/dist/subscription/react/backoff.d.ts +8 -0
  522. package/dist/subscription/react/backoff.d.ts.map +1 -0
  523. package/dist/subscription/react/classify.d.ts +15 -0
  524. package/dist/subscription/react/classify.d.ts.map +1 -0
  525. package/dist/subscription/react/controller.d.ts +40 -0
  526. package/dist/subscription/react/controller.d.ts.map +1 -0
  527. package/dist/subscription/react/fake-timers.d.ts +8 -0
  528. package/dist/subscription/react/fake-timers.d.ts.map +1 -0
  529. package/dist/subscription/react/index.d.ts +15 -0
  530. package/dist/subscription/react/index.d.ts.map +1 -0
  531. package/dist/subscription/react/index.js +227 -0
  532. package/dist/subscription/react/index.js.map +17 -0
  533. package/dist/subscription/react/reconnect.d.ts +9 -0
  534. package/dist/subscription/react/reconnect.d.ts.map +1 -0
  535. package/dist/subscription/react/scheduler.d.ts +13 -0
  536. package/dist/subscription/react/scheduler.d.ts.map +1 -0
  537. package/dist/subscription/react/timers.d.ts +7 -0
  538. package/dist/subscription/react/timers.d.ts.map +1 -0
  539. package/dist/subscription/react/use-live-subscription.d.ts +36 -0
  540. package/dist/subscription/react/use-live-subscription.d.ts.map +1 -0
  541. package/dist/subscription/react/versions.d.ts +6 -0
  542. package/dist/subscription/react/versions.d.ts.map +1 -0
  543. package/dist/subscription/read.d.ts +17 -0
  544. package/dist/subscription/read.d.ts.map +1 -0
  545. package/dist/subscription/refusal.d.ts +11 -0
  546. package/dist/subscription/refusal.d.ts.map +1 -0
  547. package/dist/subscription/relay.d.ts +16 -0
  548. package/dist/subscription/relay.d.ts.map +1 -0
  549. package/dist/vite/bun.d.ts +21 -0
  550. package/dist/vite/bun.d.ts.map +1 -0
  551. package/dist/vite/bundle.d.ts +33 -0
  552. package/dist/vite/bundle.d.ts.map +1 -0
  553. package/dist/vite/compress.d.ts +18 -0
  554. package/dist/vite/compress.d.ts.map +1 -0
  555. package/dist/vite/config.d.ts +33 -0
  556. package/dist/vite/config.d.ts.map +1 -0
  557. package/dist/vite/dev.d.ts +28 -0
  558. package/dist/vite/dev.d.ts.map +1 -0
  559. package/dist/vite/entry.d.ts +20 -0
  560. package/dist/vite/entry.d.ts.map +1 -0
  561. package/dist/vite/hosts.d.ts +16 -0
  562. package/dist/vite/hosts.d.ts.map +1 -0
  563. package/dist/vite/index.d.ts +68 -0
  564. package/dist/vite/index.d.ts.map +1 -0
  565. package/dist/vite/index.js +635 -0
  566. package/dist/vite/index.js.map +22 -0
  567. package/dist/vite/inline.d.ts +18 -0
  568. package/dist/vite/inline.d.ts.map +1 -0
  569. package/dist/vite/node.d.ts +16 -0
  570. package/dist/vite/node.d.ts.map +1 -0
  571. package/dist/vite/preview.d.ts +8 -0
  572. package/dist/vite/preview.d.ts.map +1 -0
  573. package/dist/vite/runtime.d.ts +8 -0
  574. package/dist/vite/runtime.d.ts.map +1 -0
  575. package/dist/vite/socket.d.ts +75 -0
  576. package/dist/vite/socket.d.ts.map +1 -0
  577. package/dist/vite/worker.d.ts +16 -0
  578. package/dist/vite/worker.d.ts.map +1 -0
  579. package/dist/with-alxia.d.ts +36 -0
  580. package/dist/with-alxia.d.ts.map +1 -0
  581. package/docs/README.md +42 -0
  582. package/docs/guide/api-keys.md +216 -0
  583. package/docs/guide/beside-the-pages.md +201 -0
  584. package/docs/guide/csp-nonce.md +166 -0
  585. package/docs/guide/customising-the-server.md +324 -0
  586. package/docs/guide/deploying.md +102 -0
  587. package/docs/guide/document.md +334 -0
  588. package/docs/guide/errors.md +1147 -0
  589. package/docs/guide/fetcher.md +355 -0
  590. package/docs/guide/getting-started.md +112 -0
  591. package/docs/guide/help.md +325 -0
  592. package/docs/guide/how-it-works.md +274 -0
  593. package/docs/guide/link.md +32 -0
  594. package/docs/guide/lists.md +225 -0
  595. package/docs/guide/mcp.md +173 -0
  596. package/docs/guide/media.md +273 -0
  597. package/docs/guide/navigation.md +52 -0
  598. package/docs/guide/oauth.md +342 -0
  599. package/docs/guide/oidc.md +262 -0
  600. package/docs/guide/openapi.md +51 -0
  601. package/docs/guide/pwa.md +670 -0
  602. package/docs/guide/session.md +2105 -0
  603. package/docs/guide/subscriptions.md +211 -0
  604. package/docs/guide/testing.md +42 -0
  605. package/docs/guide/typing-the-loaders.md +311 -0
  606. package/docs/guide.md +82 -0
  607. package/docs/roadmap.md +474 -0
  608. package/docs/troubleshooting.md +3837 -0
  609. package/package.json +301 -5
@@ -0,0 +1,3837 @@
1
+ # Troubleshooting
2
+
3
+ Each entry is headed by the text you see: an error thrown at startup or in
4
+ a loader, a message React Router or the browser prints, or an error from
5
+ `tsc`. Paths, route ids and types in a message are the app's own, written
6
+ `…` below. A trap that prints nothing is under [Traps](#traps), by symptom.
7
+
8
+ **Thrown or printed**
9
+
10
+ - [`docs/flows/…: <what is wrong with the front-matter>`](#docsflows-what-is-wrong-with-the-front-matter)
11
+ - [`The returned state is not the one this sign-in sent.` and the other `OidcError` messages (`/oidc`)](#the-returned-state-is-not-the-one-this-sign-in-sent-and-the-other-oidcerror-messages-oidc)
12
+ - [`capture file x.1440.light.webp is missing from docs/flows/captures/`](#capture-file-x1440lightwebp-is-missing-from-docsflowscaptures)
13
+ - [`route "x" is covered by no flow: …`](#route-x-is-covered-by-no-flow-cite-it-in-a-flows-routes-or-add-it-to-the-ignore-list)
14
+ - [`…: cites route "x", which is not in the route config`](#-cites-route-x-which-is-not-in-the-route-config)
15
+ - [`ignore "x" matches no route`](#ignore-x-matches-no-route)
16
+ - [`…: the default export must be the route config (an array)`](#-the-default-export-must-be-the-route-config-an-array)
17
+ - [`alxia-react-router: … is running on Node, and alxia's server runs on Bun. …`](#alxia-react-router--is-running-on-node-and-alxias-server-runs-on-bun-)
18
+ - [`alxia-react-router: react-router build with a service worker is running on Node, and the worker is bundled by Bun.build`](#alxia-react-router-react-router-build-with-a-service-worker-is-running-on-node-and-the-worker-is-bundled-by-bunbuild)
19
+ - [`ReferenceError: Bun is not defined`](#referenceerror-bun-is-not-defined)
20
+ - [`alxiaOf(): this request has no alxia context. …`](#alxiaof-this-request-has-no-alxia-context-)
21
+ - [`TypeError: undefined is not an object (evaluating 'context.alxia.user')`](#typeerror-undefined-is-not-an-object-evaluating-contextalxiauser)
22
+ - [`Error: No value found for context`](#error-no-value-found-for-context)
23
+ - [`alxia-react-router: … must export createServer() from @softistx/alxia-react-router as its default export: …`](#alxia-react-router--must-export-createserver-from-softistxalxia-react-router-as-its-default-export-)
24
+ - [`alxia-react-router: the entry … does not exist. …`](#alxia-react-router-the-entry--does-not-exist-)
25
+ - [`alxia-react-router: the worker … does not exist. …`](#alxia-react-router-the-worker--does-not-exist-)
26
+ - [`alxia-react-router: React Router's Vite plugin is not in this config. …`](#alxia-react-router-react-routers-vite-plugin-is-not-in-this-config-)
27
+ - [`alxia-react-router: serverBundles splits React Router's server build in several, and alxia serves one. …`](#alxia-react-router-serverbundles-splits-react-routers-server-build-in-several-and-alxia-serves-one-)
28
+ - [`alxia-react-router: Vite's ssr environment does not run modules in this process, so the server cannot be loaded.`](#alxia-react-router-vites-ssr-environment-does-not-run-modules-in-this-process-so-the-server-cannot-be-loaded)
29
+ - [`alxia-react-router: a WebSocket upgrade failed: …`](#alxia-react-router-a-websocket-upgrade-failed-)
30
+ - [`The React Router Vite plugin requires the use of a Vite config file`](#the-react-router-vite-plugin-requires-the-use-of-a-vite-config-file)
31
+ - [`No route matches URL "/assets/…"`](#no-route-matches-url-assets)
32
+ - [``You made a POST request to "/" but did not provide an `action` for route "root", so there is no way to handle the request.``](#you-made-a-post-request-to--but-did-not-provide-an-action-for-route-root-so-there-is-no-way-to-handle-the-request)
33
+ - [`TypeError: reactRouter(): client is …, which is not a directory. …`](#typeerror-reactrouter-client-is--which-is-not-a-directory-)
34
+ - [`TypeError: reactRouter(): … cannot be served at a path of its own name; rename it. …`](#typeerror-reactrouter--cannot-be-served-at-a-path-of-its-own-name-rename-it-)
35
+ - [The client's files are served uncompressed](#the-clients-files-are-served-uncompressed)
36
+ - [`Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'none'"`](#refused-to-execute-inline-script-because-it-violates-the-following-content-security-policy-directive-default-src-none)
37
+ - [`Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-…'"`](#refused-to-execute-inline-script-because-it-violates-the-following-content-security-policy-directive-script-src-self-nonce-)
38
+ - [`A tree hydrated but some attributes of the server rendered HTML didn't match the client properties`](#a-tree-hydrated-but-some-attributes-of-the-server-rendered-html-didnt-match-the-client-properties)
39
+ - [`A tree hydrated but some attributes of the server rendered HTML didn't match the client properties` on a `<style>` with a `nonce`](#a-tree-hydrated-but-some-attributes-of-the-server-rendered-html-didnt-match-the-client-properties-on-a-style-with-a-nonce)
40
+ - [`useNonce()` is undefined on the server](#usenonce-is-undefined-on-the-server)
41
+ - [`TypeError: InlineScript(): the code contains "</script" or "<!--", which ends or confuses the script element; escape it, such as "<\/script" inside a string`](#typeerror-inlinescript-the-code-contains-script-or----which-ends-or-confuses-the-script-element-escape-it-such-as-script-inside-a-string)
42
+ - [`TypeError: createPageLanguage(): the fallback … is not one of the languages; got ….`](#typeerror-createpagelanguage-the-fallback--is-not-one-of-the-languages-got-)
43
+ - [`TypeError: signInFlow(): a second factor needs both the challenge cookie (sessionCookies({ challenge })) and attemptsLeft; without one, give neither.`](#typeerror-signinflow-a-second-factor-needs-both-the-challenge-cookie-sessioncookies-challenge--and-attemptsleft-without-one-give-neither)
44
+ - [The error page shows in the fallback language](#the-error-page-shows-in-the-fallback-language)
45
+ - [`Error: You must render this element inside a <HydratedRouter> element`](#error-you-must-render-this-element-inside-a-hydratedrouter-element)
46
+ - [`alxia-react-router: … already exists, and reveal leaves it as it is. Run alxia-react-router reveal --force to overwrite it.`](#alxia-react-router--already-exists-and-reveal-leaves-it-as-it-is-run-alxia-react-router-reveal---force-to-overwrite-it)
47
+ - [`alxia-react-router: no vite.config.ts in …. Run reveal from the app's root, beside vite.config.ts.`](#alxia-react-router-no-viteconfigts-in--run-reveal-from-the-apps-root-beside-viteconfigts)
48
+ - [`alxia-react-router: … gives alxia() an entry reveal cannot read. …`](#alxia-react-router--gives-alxia-an-entry-reveal-cannot-read-)
49
+ - [`alxia-react-router: … computes appDirectory, which reveal cannot read. …`](#alxia-react-router--computes-appdirectory-which-reveal-cannot-read-)
50
+ - [`alxia-react-router: unknown command ….`](#alxia-react-router-unknown-command-)
51
+ - [`alxia-react-router: unknown option … for reveal.`](#alxia-react-router-unknown-option--for-reveal)
52
+ - [`error: GET https://registry.npmjs.org/alxia-react-router - 404`](#error-get-httpsregistrynpmjsorgalxia-react-router---404)
53
+ - [`alxia-react-router: build/server/index.js does not exist. Run react-router build before vite preview.`](#alxia-react-router-buildserverindexjs-does-not-exist-run-react-router-build-before-vite-preview)
54
+ - [`alxia-react-router: build/server/index.js is not alxia's server: its default export has no fetch. …`](#alxia-react-router-buildserverindexjs-is-not-alxias-server-its-default-export-has-no-fetch-)
55
+ - [`warn: incorrect peer dependency "typescript@5.9.3"`](#warn-incorrect-peer-dependency-typescript593)
56
+ - [`Module "…" has been externalized for browser compatibility, imported by "…"`](#module--has-been-externalized-for-browser-compatibility-imported-by-)
57
+ - [`error: lockfile had changes, but lockfile is frozen`](#error-lockfile-had-changes-but-lockfile-is-frozen)
58
+ - [`EACCES: permission denied, open '/app/…'`](#eacces-permission-denied-open-app)
59
+ - [`error: Cannot find package '…' from '/app/build/server/index.js'`](#error-cannot-find-package--from-appbuildserverindexjs)
60
+ - [`TypeError: defineWorkerContract(): cachePrefix must be a non-empty name, …`](#typeerror-defineworkercontract-cacheprefix-must-be-a-non-empty-name-)
61
+ - [`TypeError: defineWorkerContract(): cacheVersion must be a non-empty name without '-', …`](#typeerror-defineworkercontract-cacheversion-must-be-a-non-empty-name-without---)
62
+ - [`parseBrowserManifest(): not React Router's browser manifest …`](#parsebrowsermanifest-not-react-routers-browser-manifest-)
63
+ - [`error: Cannot find package 'react' from '…/@softistx/alxia-react-router/dist/pwa/react/index.js'`](#error-cannot-find-package-react-from-softistxalxia-react-routerdistpwareactindexjs)
64
+ - [`error: Cannot find package 'isbot' from '…/@softistx/alxia-react-router/dist/entry/index.js'`](#error-cannot-find-package-isbot-from-softistxalxia-react-routerdistentryindexjs)
65
+ - [`error: Cannot find package '@softistx/alxia-proxy' from '…/@softistx/alxia-react-router/dist/mcp/index.js'`](#error-cannot-find-package-softistxalxia-proxy-from-softistxalxia-react-routerdistmcpindexjs)
66
+ - [`TypeError: proxy(): the target must be an absolute URL, http:// or https://; got "…"`](#typeerror-proxy-the-target-must-be-an-absolute-url-http-or-https-got-)
67
+ - [`TypeError: proxy(): timeout must be a number of milliseconds above 0; got …`](#typeerror-proxy-timeout-must-be-a-number-of-milliseconds-above-0-got-)
68
+ - [`TypeError: mcpRelay: consent.path must start with "/"` or `consent.origin must be an http(s) origin`](#typeerror-mcprelay-consentpath-must-start-with--or-consentorigin-must-be-an-https-origin)
69
+ - [An MCP or OAuth request answers 502](#an-mcp-or-oauth-request-answers-502)
70
+ - [An MCP or OAuth request answers 413](#an-mcp-or-oauth-request-answers-413)
71
+ - [An MCP or OAuth request answers 504](#an-mcp-or-oauth-request-answers-504)
72
+ - [The API sees the proxy's address for every MCP client](#the-api-sees-the-proxys-address-for-every-mcp-client)
73
+ - [`403 {"error":"proxy_secret_required"}` on `/mcp` or `/oauth/token` of the API](#403-errorproxy_secret_required-on-mcp-or-oauthtoken-of-the-api)
74
+ - [Approving a consent request answers 400 `Bad consent request`](#approving-a-consent-request-answers-400-bad-consent-request)
75
+ - [Every consent request shows the expired state with `requireBinding`](#every-consent-request-shows-the-expired-state-with-requirebinding)
76
+ - [`startWorker(): no precache list. …`](#startworker-no-precache-list-)
77
+ - [`TypeError: startWorker(): contract is required: …`](#typeerror-startworker-contract-is-required-)
78
+ - [`error: Could not resolve: "workbox-core". Maybe you need to "bun install"?`](#error-could-not-resolve-workbox-core-maybe-you-need-to-bun-install)
79
+ - [`buildWorker() runs on Bun: it is running on Node`](#buildworker-runs-on-bun-it-is-running-on-node)
80
+ - [`buildWorker(): app/service-worker.ts does not exist.`](#buildworker-appservice-workerts-does-not-exist)
81
+ - [`buildWorker(): expected one React Router browser manifest`](#buildworker-expected-one-react-router-browser-manifest)
82
+ - [`buildWorker(): build/client/offline.html does not exist`](#buildworker-buildclientofflinehtml-does-not-exist)
83
+ - [`buildWorker(): … is outside ….`](#buildworker--is-outside-)
84
+ - [`buildWorker(): Bun.build failed:`](#buildworker-bunbuild-failed)
85
+ - [`Cross-site request refused`](#cross-site-request-refused)
86
+ - [`Expected a JSON body`](#expected-a-json-body)
87
+ - [`Malformed JSON body`](#malformed-json-body)
88
+ - [`The form sent an input the API would refuse`](#the-form-sent-an-input-the-api-would-refuse)
89
+ - [`alxia-react-router: the error catalogue (…) was not read`](#alxia-react-router-the-error-catalogue--was-not-read)
90
+ - [`alxia-react-router: the error catalogue was not checked, keeping what is held`](#alxia-react-router-the-error-catalogue-was-not-checked-keeping-what-is-held)
91
+ - [`alxia-react-router: the error catalogue was not warmed`](#alxia-react-router-the-error-catalogue-was-not-warmed)
92
+ - [`alxia-react-router: ttlMs threw, using retryMs`](#alxia-react-router-ttlms-threw-using-retryms)
93
+ - [`alxia-react-router: ttlMs is not a duration, using retryMs`](#alxia-react-router-ttlms-is-not-a-duration-using-retryms)
94
+ - [`TypeError: createErrorCatalogue(): needs at least one language.`](#typeerror-createerrorcatalogue-needs-at-least-one-language)
95
+ - [`<api>: <operation> (request <id>) answered <status> <code>`](#api-operation-request-id-answered-status-code)
96
+ - [`<api>: <operation> (request <id>) answered <status> without GraphQL`](#api-operation-request-id-answered-status-without-graphql)
97
+ - [`<api>: <operation> (request <id>) unreachable`, `timeout` or `invalid-response`](#api-operation-request-id-unreachable-timeout-or-invalid-response)
98
+ - [`<api>: <operation> (request <id>) aborted`](#api-operation-request-id-aborted)
99
+ - [`TypeError: sessionCookies(): the … name "…" is not a cookie name (an RFC 6265 token: …). Pass a name such as "my-app_session".`](#typeerror-sessioncookies-the--name--is-not-a-cookie-name-an-rfc-6265-token--pass-a-name-such-as-my-app_session)
100
+ - [`TypeError: sessionCookies(): the … name "…" already carries a prefix. Pass the base name: the package adds __Host- (session) or __Secure- (challenge) when secure is true.`](#typeerror-sessioncookies-the--name--already-carries-a-prefix-pass-the-base-name-the-package-adds-__host--session-or-__secure--challenge-when-secure-is-true)
101
+ - [`TypeError: sessionCookies(): challengeHostPrefix needs challengePath: "/" ...`](#typeerror-sessioncookies-challengehostprefix-needs-challengepath--a-__host--cookie-must-have-path-got-)
102
+ - [`TypeError: sessionCookies(): challengeSeconds must be a positive integer; got ….`](#typeerror-sessioncookies-challengeseconds-must-be-a-positive-integer-got-)
103
+ - [`TypeError: sessionCookies(): challengePath must start with "/" and hold no ";" or control character; got ….`](#typeerror-sessioncookies-challengepath-must-start-with--and-hold-no--or-control-character-got-)
104
+ - [`TypeError: sessionCookies(): sameSite must be "lax", "strict" or "none"; got ….`](#typeerror-sessioncookies-samesite-must-be-lax-strict-or-none-got-)
105
+ - [`TypeError: sessionCookies(): sameSite "none" needs secure: true, since a browser drops a SameSite=None cookie without Secure.`](#typeerror-sessioncookies-samesite-none-needs-secure-true-since-a-browser-drops-a-samesitenone-cookie-without-secure)
106
+ - [`TypeError: signedSession(): secret must be a string of at least 32 characters.`](#typeerror-signedsession-secret-must-be-a-string-of-at-least-32-characters)
107
+ - [`TypeError: signedSession(): the name "…" must be an RFC 6265 token without a __Host- or __Secure- prefix; …` or `maxAge must be a positive integer of seconds; got ….`](#typeerror-signedsession-the-name--must-be-an-rfc-6265-token-without-a-__host--or-__secure--prefix--or-maxage-must-be-a-positive-integer-of-seconds-got-)
108
+ - [`TypeError: createSignInThrottle(): globalMode must be 'refuse' or 'delay'; got ….`](#typeerror-createsigninthrottle-globalmode-must-be-refuse-or-delay-got-)
109
+ - [`TypeError: createSignInThrottle(): … must be a positive integer; got ….` or `… must be a positive integer or 0; got ….`](#typeerror-createsigninthrottle--must-be-a-positive-integer-got--or--must-be-a-positive-integer-or-0-got-)
110
+ - [`TypeError: signInFlow(): paths.… must be a path of this site with no query or fragment, starting with a single "/"; got ….`](#typeerror-signinflow-paths-must-be-a-path-of-this-site-with-no-query-or-fragment-starting-with-a-single--got-)
111
+ - [`TypeError: signInPath(): options.path must be a path of this site with no query or fragment, starting with a single "/"; got ….`](#typeerror-signinpath-optionspath-must-be-a-path-of-this-site-with-no-query-or-fragment-starting-with-a-single--got-)
112
+ - [`TypeError: signInFlow(): json must come from jsonActions(), which carries the site check every step runs; this object has none (a hand-made double?). Pass the app's jsonActions({ origin }) instance, or a spread copy of it.`](#typeerror-signinflow-json-must-come-from-jsonactions-which-carries-the-site-check-every-step-runs-this-object-has-none-a-hand-made-double-pass-the-apps-jsonactions-origin--instance-or-a-spread-copy-of-it)
113
+ - [`TypeError: signInFlow(): the code "…" is both the wrong-code code (codes.invalidCode) and in codes.challengeOver. A wrong code that leaves tries cannot end the challenge.`](#typeerror-signinflow-the-code--is-both-the-wrong-code-code-codesinvalidcode-and-in-codeschallengeover-a-wrong-code-that-leaves-tries-cannot-end-the-challenge)
114
+ - [`TypeError: serializeCookie(): the name "…" is not a cookie name (an RFC 6265 token).`](#typeerror-serializecookie-the-name--is-not-a-cookie-name-an-rfc-6265-token)
115
+ - [`TypeError: serializeCookie(): the path "…" is not a cookie path: it must start with "/" and hold no ";" or control character.`](#typeerror-serializecookie-the-path--is-not-a-cookie-path-it-must-start-with--and-hold-no--or-control-character)
116
+ - [`TypeError: statePath(): a token page's path must be a path of this site with no query or fragment, starting with a single "/"; got ….`](#typeerror-statepath-a-token-pages-path-must-be-a-path-of-this-site-with-no-query-or-fragment-starting-with-a-single--got-)
117
+ - [`TypeError: linkArgs(): a token page's path must be a path of this site with no query or fragment, starting with a single "/"; got ….`](#typeerror-linkargs-a-token-pages-path-must-be-a-path-of-this-site-with-no-query-or-fragment-starting-with-a-single--got-)
118
+ - [`TypeError: spendToken(): a token page's path must be a path of this site with no query or fragment, starting with a single "/"; got ….`](#typeerror-spendtoken-a-token-pages-path-must-be-a-path-of-this-site-with-no-query-or-fragment-starting-with-a-single--got-)
119
+ - [`TypeError: authLinks(): resetDone must be a path of this site, starting with a single "/"; got ….`](#typeerror-authlinks-resetdone-must-be-a-path-of-this-site-starting-with-a-single--got-)
120
+ - [`Type '…' is not assignable to type 'undefined'` passing a context to a step](#type--is-not-assignable-to-type-undefined-passing-a-context-to-a-step)
121
+ - [`503 unavailable` from the `health` probe](#503-unavailable-from-the-health-probe)
122
+ - [`GET /health is declared twice: keep one; …`](#get-health-is-declared-twice-keep-one-)
123
+
124
+ **Types**
125
+
126
+ - [`Property 'alxia' does not exist on type 'Readonly<RouterContextProvider>'`](#property-alxia-does-not-exist-on-type-readonlyroutercontextprovider)
127
+ - [`Property '…' does not exist on type 'BaseContext & …'`](#property--does-not-exist-on-type-basecontext--)
128
+ - [`Type '…' does not satisfy the constraint 'AnyAlxia | ReactRouterServer<AnyAlxia>'`](#type--does-not-satisfy-the-constraint-anyalxia--reactrouterserveranyalxia)
129
+ - [`Type '(app: …) => void' is not assignable to type '(app: …) => AnyAlxia'`](#type-app---void-is-not-assignable-to-type-app---anyalxia)
130
+ - [`Property '…' does not exist on type 'BaseContext & { readonly 'Register.server must be typeof server, the default export of createServer()': never; }'`](#property--does-not-exist-on-type-basecontext---readonly-registerserver-must-be-typeof-server-the-default-export-of-createserver-never-)
131
+ - [`Subsequent property declarations must have the same type. Property 'server' must be of type …`](#subsequent-property-declarations-must-have-the-same-type-property-server-must-be-of-type-)
132
+ - [`Type '{ …; nonce: string | undefined; }' is not assignable to type 'ServerRouterProps' with 'exactOptionalPropertyTypes: true'`](#type---nonce-string--undefined--is-not-assignable-to-type-serverrouterprops-with-exactoptionalpropertytypes-true)
133
+
134
+ **Traps**
135
+
136
+ - [`bun build/server/index.js` exits at once, printing nothing](#bun-buildserverindexjs-exits-at-once-printing-nothing)
137
+ - [A script of the page has no nonce](#a-script-of-the-page-has-no-nonce)
138
+ - [A loader reads `null` from the app's own key](#a-loader-reads-null-from-the-apps-own-key)
139
+ - [A page answers alxia's JSON 404 or 405 instead of rendering](#a-page-answers-alxias-json-404-or-405-instead-of-rendering)
140
+ - [A streamed page arrives in one piece](#a-streamed-page-arrives-in-one-piece)
141
+ - [The logger times a streamed page at a few milliseconds](#the-logger-times-a-streamed-page-at-a-few-milliseconds)
142
+ - [A page, or a missing path, answers 401 behind a guard](#a-page-or-a-missing-path-answers-401-behind-a-guard)
143
+ - [The logger, CORS or secure headers miss the client's files](#the-logger-cors-or-secure-headers-miss-the-clients-files)
144
+ - [A `page()` is not served under `react-router dev`](#a-page-is-not-served-under-react-router-dev)
145
+ - [A `publish` under `react-router dev` misses the sockets opened before an edit](#a-publish-under-react-router-dev-misses-the-sockets-opened-before-an-edit)
146
+ - [The build has a package's Node variant, not its `bun` one](#the-build-has-a-packages-node-variant-not-its-bun-one)
147
+ - [`request.url` in a loader is `http://` and the internal host behind a proxy](#requesturl-in-a-loader-is-http-and-the-internal-host-behind-a-proxy)
148
+ - [An unhashed file under `public/assets/` is cached for a year](#an-unhashed-file-under-publicassets-is-cached-for-a-year)
149
+ - [A cache the contract did not make is swept](#a-cache-the-contract-did-not-make-is-swept)
150
+ - [The update notice never shows](#the-update-notice-never-shows)
151
+ - [The worker registers under `react-router dev`](#the-worker-registers-under-react-router-dev)
152
+ - [The service worker is not built](#the-service-worker-is-not-built)
153
+ - [Offline, a client navigation to a route never visited shows the offline page](#offline-a-client-navigation-to-a-route-never-visited-shows-the-offline-page)
154
+ - [An update waits an hour](#an-update-waits-an-hour)
155
+ - [The worker cannot fetch another origin](#the-worker-cannot-fetch-another-origin)
156
+ - [The manifest is in the wrong language](#the-manifest-is-in-the-wrong-language)
157
+ - [A form's own check shows the code (`todos.errors.…`) instead of words](#a-forms-own-check-shows-the-code-todoserrors-instead-of-words)
158
+ - [A message shows its `{braces}`](#a-message-shows-its-braces)
159
+ - [A refusal shows the API's raw message](#a-refusal-shows-the-apis-raw-message)
160
+ - [`apiRefusal` returns undefined](#apirefusal-returns-undefined)
161
+ - [The error page shows no request id](#the-error-page-shows-no-request-id)
162
+ - [An action shows the error page](#an-action-shows-the-error-page)
163
+ - [Behind a TLS proxy every action answers 403](#behind-a-tls-proxy-every-action-answers-403)
164
+ - [Right after start, refusals read in the API's words](#right-after-start-refusals-read-in-the-apis-words)
165
+ - [`next` is always `/`](#next-is-always-)
166
+ - [Sign-in loops on `http://localhost` in Safari](#sign-in-loops-on-httplocalhost-in-safari)
167
+ - [A `__Host-` cookie is dropped](#a-__host--cookie-is-dropped)
168
+ - [A token page's token shows in a Referer or a search result](#a-token-pages-token-shows-in-a-referer-or-a-search-result)
169
+ - [`Blocked request. This host ("…") is not allowed.`](#blocked-request-this-host--is-not-allowed)
170
+
171
+ ## Thrown or printed
172
+
173
+ ### `503 unavailable` from the `health` probe
174
+
175
+ `createServer({ health: { check } })` answers `503` `unavailable` when
176
+ `check` returned `false`, threw, rejected, or did not settle within
177
+ `timeout` (1 000 ms by default). The error is not logged: call the check
178
+ yourself to see it. A `check` that returns nothing counts as healthy.
179
+
180
+ Two traps:
181
+
182
+ - A `/health` declared in `configure` or `beforeAll`, or core's `health()`
183
+ mounted there with its default path, is not shadowed: the app throws at
184
+ startup, see the next entry.
185
+ - A check that never settles holds the probe until `timeout`, then answers
186
+ 503. Lower `timeout` if the platform's probe gives up sooner.
187
+
188
+ ```ts
189
+ createServer({ health: { check: () => db.ping(), timeout: 500 } });
190
+ ```
191
+
192
+ ### `GET /health is declared twice: keep one; …`
193
+
194
+ **When:** `createServer({ health })` and another route or plugin declare the
195
+ same path: a `/health` route in `configure` or `beforeAll`, or `health()`
196
+ mounted with its default `path`. The server throws when it is created.
197
+
198
+ **Why:** the probe is declared first, and a method and path may be declared
199
+ once.
200
+
201
+ **Fix:** keep one. Drop the hand-written route, or give the other one
202
+ another path:
203
+
204
+ ```ts
205
+ createServer({
206
+ health: '/health',
207
+ beforeAll: (app) => app.plugin(health({ path: '/live' })),
208
+ });
209
+ ```
210
+
211
+ See also core's [declared
212
+ twice](https://github.com/softistx/alxia/blob/develop/packages/core/docs/troubleshooting.md#get--is-declared-twice).
213
+
214
+ ### `Not a step-up intent` (a 400 from `stepUp.route`)
215
+
216
+ **When:** a page posts to the route that serves `stepUpSteps().route` with an
217
+ `intent` other than `request-step-up` or `confirm-step-up`, or a
218
+ `confirm-step-up` whose `challenge` or `code` is not a string.
219
+
220
+ **Why:** `route()` answers only those two intents and runs nothing else.
221
+
222
+ **Fix:** post the intents with the fields `useStepUp` gives your `confirm.post`
223
+ (`challenge`, `code`, `via`), as JSON:
224
+
225
+ ```ts
226
+ confirm.submit(
227
+ { intent: 'confirm-step-up', challenge, code, via },
228
+ { method: 'post', action: '/step-up', encType: 'application/json' },
229
+ );
230
+ ```
231
+
232
+ ### `alxia-react-router: … is running on Node, and alxia's server runs on Bun. …`
233
+
234
+ **When:** `bun run dev`, `vite preview`, or a `react-router build` that
235
+ prerenders or builds a service worker (`app/service-worker.ts`), on a machine
236
+ where a node is installed. The full message under `react-router dev`:
237
+
238
+ ```
239
+ alxia-react-router: react-router dev is running on Node, and alxia's server runs on Bun. Add a bunfig.toml beside package.json with "[run]" and "bun = true", so bun run starts it on Bun, or run it as bun --bun react-router dev.
240
+ ```
241
+
242
+ **Why:** the `react-router` and `vite` CLIs start with
243
+ `#!/usr/bin/env node`. `bun run` honours that line when a node is on the
244
+ `PATH`, so the dev server, and alxia's server inside it, run on Node,
245
+ where `Bun` does not exist.
246
+
247
+ **Fix:** a `bunfig.toml` beside `package.json`, so `bun run` starts every
248
+ script on Bun:
249
+
250
+ ```toml
251
+ [run]
252
+ bun = true
253
+ ```
254
+
255
+ Or run the one command on Bun: `bun --bun react-router dev`. Under
256
+ `vite preview` or a prerendering build, the message begins
257
+ `alxia-react-router: vite preview, or a react-router build that prerenders, is running on Node`
258
+ and names `bun --bun vite preview` and `bun --bun react-router build`. A
259
+ build that has a service worker reads
260
+ `alxia-react-router: react-router build with a service worker is running on Node, and the worker is bundled by Bun.build`
261
+ and names the same `bun --bun react-router build`.
262
+
263
+ ### `alxia-react-router: react-router build with a service worker is running on Node, and the worker is bundled by Bun.build`
264
+
265
+ The same cause as
266
+ [the entry above](#alxia-react-router--is-running-on-node-and-alxias-server-runs-on-bun-):
267
+ the build runs on Node, and the worker is bundled with `Bun.build`. Run it as
268
+ `bun --bun react-router build`, or add a `bunfig.toml` beside `package.json`
269
+ with `[run]` and `bun = true`.
270
+
271
+ ### `ReferenceError: Bun is not defined`
272
+
273
+ **When:** the first request to a page, with a stack through the app's
274
+ own code or alxia's, from a server running on Node that the plugin did
275
+ not start, so it could not refuse it: `node build/server/index.js`, or a
276
+ `start` script that runs one.
277
+
278
+ **Fix:** run the server on Bun: `bun build/server/index.js`. Under
279
+ `react-router dev` or `vite preview`, the plugin refuses Node at startup
280
+ with [the entry above](#alxia-react-router--is-running-on-node-and-alxias-server-runs-on-bun-).
281
+
282
+ ### `alxiaOf(): this request has no alxia context. …`
283
+
284
+ ```text
285
+ Error: alxiaOf(): this request has no alxia context. Serve the React Router app through alxia: add alxia() from @softistx/alxia-react-router/vite to vite.config.ts's plugins, or, with a server of your own, serve the build through reactRouter() from @softistx/alxia-react-router.
286
+ ```
287
+
288
+ **When:** a loader calls `alxiaOf`, or reads `context.alxia`, and
289
+ `alxiaContext` was not set. `context.alxia` throws the same error: it reads
290
+ that key. With two copies of `@softistx/alxia-react-router` in one process (the
291
+ third case below), the getter is the copy loaded last, which reads its own
292
+ key: one copy is the fix for both.
293
+
294
+ **Why:** one of three:
295
+
296
+ - the request did not go through alxia: `vite.config.ts` has no `alxia()`,
297
+ the build runs under `react-router-serve`, or a unit test calls the
298
+ loader with a bare `RouterContextProvider`;
299
+ - a server of your own, without the plugin, serves the build without
300
+ `reactRouter()`;
301
+ - a server of your own, without the plugin, in a monorepo: the server
302
+ build holds **its own copy** of `@softistx/alxia-react-router`. Vite leaves a
303
+ package external only when it resolves under `node_modules` to a `.js`
304
+ file. A package linked from a workspace (`workspace:^`, `bun link`)
305
+ resolves to its folder, outside `node_modules`, and Vite bundles it into
306
+ `build/server/index.js` with a second `alxiaContext` the server never
307
+ sets.
308
+
309
+ **Fix:** add `alxia()` to `vite.config.ts`, as in the
310
+ [setup](guide/getting-started.md). With a server of your own in a monorepo, tell
311
+ Vite to leave the package external:
312
+
313
+ ```ts
314
+ // vite.config.ts
315
+ import { reactRouter } from '@react-router/dev/vite';
316
+ import { defineConfig } from 'vite';
317
+
318
+ export default defineConfig({
319
+ ssr: { external: ['@softistx/alxia-react-router'] },
320
+ plugins: [reactRouter()],
321
+ });
322
+ ```
323
+
324
+ `grep '@softistx/alxia-react-router' build/server/index.js` should show an
325
+ `import … from "@softistx/alxia-react-router"` line, not the package's code. In a
326
+ unit test, set the key yourself:
327
+
328
+ ```ts
329
+ import { alxiaContext } from '@softistx/alxia-react-router';
330
+ import { RouterContextProvider } from 'react-router';
331
+
332
+ const context = new RouterContextProvider();
333
+ context.set(alxiaContext, { user: { name: 'Ada' } });
334
+ await loader({ context, request: new Request('http://localhost/'), params: {} } as never);
335
+ ```
336
+
337
+ ### `TypeError: undefined is not an object (evaluating 'context.alxia.user')`
338
+
339
+ **When:** a unit test calls a loader that reads `context.alxia` with a
340
+ `new RouterContextProvider()`, and nothing in the test imports
341
+ `@softistx/alxia-react-router`; destructured, `const { user } = context.alxia` fails
342
+ with `TypeError: Cannot destructure property 'user' from null or undefined
343
+ value`. A `clientLoader` or a `clientAction` reading it fails the same way
344
+ in the browser.
345
+
346
+ **Why:** `context.alxia` is a getter `@softistx/alxia-react-router` defines on React
347
+ Router's provider when it is first imported. The loader's module need not
348
+ import it, and the browser never loads it: the alxia context is the
349
+ server's.
350
+
351
+ **Fix:** in the test, set the key the getter reads, imported from
352
+ `@softistx/alxia-react-router`, which installs the getter:
353
+
354
+ ```ts
355
+ import { alxiaContext } from '@softistx/alxia-react-router';
356
+ import { RouterContextProvider } from 'react-router';
357
+
358
+ const context = new RouterContextProvider();
359
+ context.set(alxiaContext, { user: { name: 'Ada' }, server: undefined });
360
+ await loader({ context, request: new Request('http://localhost/'), params: {} } as never);
361
+ ```
362
+
363
+ On the client, read the data the server's loader returned instead.
364
+
365
+ ### `Error: No value found for context`
366
+
367
+ **When:** a loader, action or middleware calls `context.get(key)` with a
368
+ key made by `createContext()` with no default value, in a file under
369
+ `app/`, and a server of your own, without the plugin, set it in
370
+ `getLoadContext`.
371
+
372
+ **Why:** `react-router build` bundles `app/context.ts` into
373
+ `build/server/index.js`. A server outside the build, which imports
374
+ `app/context.ts` itself, holds another `createContext()` object. React
375
+ Router matches keys by identity, so that server's
376
+ `context.set(userContext, user)` sets a key the loaders never read.
377
+
378
+ ```ts
379
+ // server.ts, without the plugin: the trap
380
+ import { userContext } from './app/context'; // not the build's copy
381
+ reactRouter(app, { build, getLoadContext: ({ user }, context) => context.set(userContext, user) });
382
+ ```
383
+
384
+ **Fix:** serve the app with the plugin, `alxia()` in `vite.config.ts`: the
385
+ server is then built with the routes, and `app/context.ts` is one module
386
+ for both, in dev and in the build. See
387
+ [the app's own context keys](guide/typing-the-loaders.md#the-apps-own-context-keys).
388
+
389
+ Without the plugin, read alxia's context with `alxiaOf`: its key,
390
+ `alxiaContext`, lives in this package under `node_modules`, which Vite
391
+ leaves external, so the build and the server load one module. A key
392
+ exported by a package installed under `node_modules` (`@acme/session`)
393
+ works for the same reason.
394
+
395
+ ### `alxia-react-router: … must export createServer() from @softistx/alxia-react-router as its default export: …`
396
+
397
+ ```text
398
+ TypeError: alxia-react-router: app/server.ts must export createServer() from @softistx/alxia-react-router as its default export: export default createServer({ … }).
399
+ ```
400
+
401
+ Under `react-router dev`, Vite's error page shows it, and the request is a
402
+ 500. In a build, `bun build/server/index.js` throws it at startup.
403
+
404
+ **When:** the server file has no default export, or its default is not
405
+ what `createServer()` returns: an alxia app, a named `export const server`,
406
+ or the options object itself.
407
+
408
+ **Why:** the plugin makes the app with the default export's `create`, and
409
+ listens with its `start`.
410
+
411
+ **Fix:** export the server as the default:
412
+
413
+ ```ts
414
+ // app/server.ts
415
+ import { createServer } from '@softistx/alxia-react-router';
416
+
417
+ const server = createServer({ configure: (app) => app });
418
+ export default server;
419
+ ```
420
+
421
+ An alxia app of your own, with `reactRouter()` on it, is served without the
422
+ plugin: see [a server of your own](guide/customising-the-server.md#a-server-of-your-own-without-the-plugin).
423
+
424
+ ### `alxia-react-router: the entry … does not exist. …`
425
+
426
+ ```text
427
+ Error: alxia-react-router: the entry server/main.ts does not exist. Create it, or leave entry out to use app/server.ts, or the default server without it.
428
+ ```
429
+
430
+ **When:** `alxia({ entry })` names a file that is not there, relative to
431
+ Vite's root. Under `react-router dev` each request is a 500 saying so;
432
+ `react-router build` fails.
433
+
434
+ **Why:** a missing `app/server.ts` falls back to the default server, but an
435
+ `entry` you named is taken as meant.
436
+
437
+ **Fix:** correct the path, or leave `entry` out.
438
+
439
+ ### `alxia-react-router: the worker … does not exist. …`
440
+
441
+ ```text
442
+ Error: alxia-react-router: the worker app/pwa/worker.ts does not exist. Create it, or leave worker out to build app/service-worker.ts when it exists.
443
+ ```
444
+
445
+ **When:** `alxia({ worker })` names a file that is not there, relative to
446
+ Vite's root, and `react-router build` fails.
447
+
448
+ **Why:** a missing `app/service-worker.ts` just means no worker, but a
449
+ `worker` you named is taken as meant.
450
+
451
+ **Fix:** correct the path, or leave `worker` out.
452
+
453
+ ### `alxia-react-router: React Router's Vite plugin is not in this config. …`
454
+
455
+ ```text
456
+ Error: alxia-react-router: React Router's Vite plugin is not in this config. Add reactRouter() from @react-router/dev/vite beside alxia() in vite.config.ts.
457
+ ```
458
+
459
+ **When:** Vite starts, for `react-router dev`, `react-router build` or
460
+ `vite`, with `alxia()` and no `reactRouter()`.
461
+
462
+ **Why:** the plugin reads React Router's config (the app directory, the
463
+ build directory, the server build's file name) from React Router's own
464
+ plugin.
465
+
466
+ **Fix:** list both, in any order:
467
+
468
+ ```ts
469
+ // vite.config.ts
470
+ import { alxia } from '@softistx/alxia-react-router/vite';
471
+ import { reactRouter } from '@react-router/dev/vite';
472
+ import { defineConfig } from 'vite';
473
+
474
+ export default defineConfig({ plugins: [reactRouter(), alxia()] });
475
+ ```
476
+
477
+ ### `alxia-react-router: serverBundles splits React Router's server build in several, and alxia serves one. …`
478
+
479
+ ```text
480
+ Error: alxia-react-router: serverBundles splits React Router's server build in several, and alxia serves one. Remove serverBundles from react-router.config.ts.
481
+ ```
482
+
483
+ **When:** `react-router.config.ts` sets `serverBundles`.
484
+
485
+ **Why:** the plugin builds one server, `build/server/index.js`, with React
486
+ Router's build inside it. Server bundles make several, each its own
487
+ `index.js`.
488
+
489
+ **Fix:** remove `serverBundles`. One alxia server serves every route.
490
+
491
+ ### `alxia-react-router: Vite's ssr environment does not run modules in this process, so the server cannot be loaded.`
492
+
493
+ **When:** under `react-router dev`, Vite's `ssr` environment is not a
494
+ runnable one: another plugin replaced it with an environment that runs
495
+ elsewhere, such as a worker runtime.
496
+
497
+ **Why:** the plugin loads the server with the `ssr` environment's module
498
+ runner, in Vite's own process, where Bun runs the app. The check reads the
499
+ environment's `runner` itself, so an app whose Vite is another copy than
500
+ the one this package was tested with passes it.
501
+
502
+ **Fix:** drop the plugin that replaces the `ssr` environment. alxia runs
503
+ under Bun, not in a worker runtime.
504
+
505
+ ### `alxia-react-router: a WebSocket upgrade failed: …`
506
+
507
+ Printed by Vite's logger, followed by the error's stack.
508
+
509
+ **When:** under `react-router dev`, a client opens a WebSocket to the app,
510
+ and loading the server throws: `app/server.ts`, or a module it imports,
511
+ throws when it runs or does not compile, or the plugin itself fails (the
512
+ prefix is then followed by its own message, such as `Vite's ssr
513
+ environment does not run modules in this process`). Under `vite preview`,
514
+ the built server failed to load: the prefix is followed by
515
+ [`… does not exist. Run react-router build before vite preview.`](#alxia-react-router-buildserverindexjs-does-not-exist-run-react-router-build-before-vite-preview)
516
+ or [`… is not alxia's server: …`](#alxia-react-router-buildserverindexjs-is-not-alxias-server-its-default-export-has-no-fetch-),
517
+ whose fixes apply. The client's handshake gets a `500`, and no socket.
518
+
519
+ **Why:** the plugin loads the server, through Vite's SSR runner, on each
520
+ upgrade as on each request, so that an edit is used from the next
521
+ connection. An HTTP request with the same error goes to Vite's error
522
+ page; an upgrade has no page to show, so the error is printed.
523
+
524
+ **Fix:** fix the error the stack names. The next connection loads the
525
+ server again, with no restart.
526
+
527
+ ### `The React Router Vite plugin requires the use of a Vite config file`
528
+
529
+ React Router's Vite plugin throws it.
530
+
531
+ **When:** a script or a test starts Vite with `createServer({
532
+ configFile: false, plugins: [alxia(), reactRouter()] })`.
533
+
534
+ **Why:** React Router's plugin reads its options from a config file, and
535
+ refuses inline ones.
536
+
537
+ **Fix:** write the config to a file, and point `configFile` at it:
538
+
539
+ ```ts
540
+ import { createServer } from 'vite';
541
+
542
+ const server = await createServer({
543
+ root,
544
+ configFile: `${root}/vite.config.ts`,
545
+ server: { port: 0 },
546
+ });
547
+ await server.listen();
548
+ ```
549
+
550
+ ### `No route matches URL "/assets/…"`
551
+
552
+ React Router's 404 page answers every file under `/assets`.
553
+
554
+ **When:** in a build, the server runs in `development`: `createServer({
555
+ mode: 'development' })`, or a server of your own with `reactRouter(app, {
556
+ mode: 'development' })`.
557
+
558
+ **Why:** in `development` the client's files are left to Vite's dev
559
+ server, so nothing serves `build/client`, and the catch-all gets the
560
+ assets. Under the plugin the mode follows the command, `production` in a
561
+ build, whatever `NODE_ENV` says; only an explicit `mode` changes it.
562
+
563
+ **Fix:** leave `mode` out, or set it from where the server runs:
564
+
565
+ ```ts
566
+ // server.ts, without the plugin
567
+ reactRouter(app, { build, client: 'build/client', mode: 'production' });
568
+ ```
569
+
570
+ ### A link form shows "Something went wrong. Try again.", or a success after a refused token
571
+
572
+ **When:** a page posts to a mail-link route with `fetch` and the form shows
573
+ "Something went wrong. Try again." (or the app's own `unreachable` option
574
+ text of `postLinkRequest` / `postLinkArgs`), or shows success after a
575
+ refused token.
576
+
577
+ **Why:** `linkArgs` and the link helpers answer with a 302, and `fetch`
578
+ follows it and reads the next page. Or the route has a component: React
579
+ Router then answers a `fetch` POST with the page's HTML, not the action's JSON.
580
+
581
+ **Fix:** make the route a resource route (an `action` and no default
582
+ export), wrap the action in `handingOver`, and post with `postLinkArgs` or
583
+ `postLinkRequest`, which send the `X-Alxia-Link: json` header it looks for.
584
+ Give it a path of its own (`/reset/submit` beside the `/reset` page, since
585
+ two routes cannot serve one path), and a `loader` that redirects to the
586
+ page for the GET a native post is sent back to. See
587
+ [the guide](guide/session.md#a-page-that-posts-with-fetch).
588
+
589
+ ### ``You made a POST request to "/" but did not provide an `action` for route "root", so there is no way to handle the request.``
590
+
591
+ React Router prints it, and answers `405`.
592
+
593
+ **When:** a `POST /` to an app whose index route has the action.
594
+
595
+ **Why:** a `POST /` is the root route's. The index route's action is
596
+ `POST /?index`; React Router's own `<Form>` adds `?index` when it posts
597
+ from an index route. This is React Router's behaviour, not alxia's.
598
+
599
+ **Fix:** post to `/?index`, as `<Form method="post">` does, or in a test:
600
+
601
+ ```ts
602
+ await app.request('/?index', { method: 'POST', body: new URLSearchParams({ step: '2' }) });
603
+ ```
604
+
605
+ The single-fetch form is `POST /_.data?index`.
606
+
607
+ ### `RangeError: connectionPage(): wanted must be an integer of at least 1; got …`
608
+
609
+ `connectionPage` (`/lists`) was given a `wanted` page, a `pageSize` or a
610
+ `maxFirst` (the message names which) that is not a whole number of at least 1.
611
+ It is most often an unchecked `?page=`: `Number('abc')` is `NaN`, and `?page=0`
612
+ or `?page=-2` reach the loader as they are. Check the parameter first:
613
+
614
+ ```ts
615
+ const asked = Number(new URL(request.url).searchParams.get('page') ?? 1);
616
+ const wanted = Number.isInteger(asked) && asked >= 1 ? asked : 1;
617
+ const result = await connectionPage(wanted, 20, fetchPage);
618
+ ```
619
+
620
+ ### `TypeError: socialRoutes(): paths.base must be a path of this site with no query or fragment, starting with a single "/"; got …`
621
+
622
+ `paths.base`, `paths.signIn` or `paths.secondFactor` (the message names which)
623
+ is not a path of this site: it has no leading `/`, starts with `//`, or holds a
624
+ `?` or `#`.
625
+
626
+ ```ts
627
+ socialRoutes({ /* … */ paths: { base: '/auth', signIn: '/sign-in' } });
628
+ ```
629
+
630
+ ### `TypeError: socialRoutes(): flowCookie.name "…" must be an RFC 6265 cookie name with no __Secure- or __Host- prefix …`
631
+
632
+ `flowCookie.name` holds a character a cookie name cannot (a space, `;`, `=`), or
633
+ already carries `__Secure-` or `__Host-`. Give the base name: the package adds
634
+ `__Secure-` when `secure` is true.
635
+
636
+ ```ts
637
+ socialRoutes({ flowCookie: { secure: true, name: 'my_social_flow' } /* … */ });
638
+ ```
639
+
640
+ ### `TypeError: socialRoutes(): flowCookie.seconds must be a finite number above 0; got …`
641
+
642
+ `flowCookie.seconds` is `0`, negative, `NaN` or `Infinity`. It is the time the
643
+ sign-in may take at the provider; the default is 600.
644
+
645
+ ```ts
646
+ socialRoutes({ flowCookie: { secure: true, seconds: 600 } /* … */ });
647
+ ```
648
+
649
+ ### `404 Not Found` from `/auth/:provider`, its link or its callback
650
+
651
+ The `:provider` of the URL is not in `providers`, or `link` was mounted
652
+ without a `linkStart`. `start`, `link` and `callback` throw the 404 before reading the cookie or calling the API.
653
+
654
+ ```ts
655
+ socialRoutes({ providers: ['google', 'github'] /* … */ });
656
+ ```
657
+
658
+ ### A provider link lands back with `?error=social_cross_site`
659
+
660
+ **When:** the link URL (`/auth/:provider/link`) is opened by a request whose `Sec-Fetch-Site` is any value but `same-origin` and `none` (`cross-site`, `same-site`…): a link or redirect on another site, or on a sibling subdomain.
661
+
662
+ **Why:** the session cookie is `SameSite=Lax`, so such a navigation carries it, and a page must not start a link for a visitor. `link` refuses it before `linkStart` runs and sets no cookie. A request with `same-origin` or `none` (a typed URL, a bookmark) goes on. With no header (Safari before 16.4, old browsers) the guard cannot tell, so the link goes on and only the `SameSite=Lax` cookie protects it: a missing header never raises this error.
663
+
664
+ **Fix:** start the link from your own page, with a `<Link>` or a `<Form method="get">` that navigates inside the app (`same-origin`). To show another message, read the code from `errorParam` on the link landing (`?error=social_cross_site`, see [Linking a provider](guide/session.md#linking-a-provider)); `crossSiteCode` renames it.
665
+
666
+ ```ts
667
+ socialRoutes({ /* … */ crossSiteCode: 'link_refused' });
668
+ ```
669
+
670
+ ### A provider link lands back with `?error=invalid_session`
671
+
672
+ **When:** `complete` answers `session` or `secondFactor` for a link flow.
673
+
674
+ **Why:** the callback knows the flow is a link (`kind: 'link'`) and only a `linked` or `error` outcome fits it.
675
+
676
+ **Fix:** branch on `kind` in `complete` and answer `{ kind: 'linked' }` for a link.
677
+
678
+ ```ts no-check
679
+ complete: (input, { kind }) => kind === 'link' ? api.link(input) : api.signIn(input),
680
+ ```
681
+
682
+ ### `TypeError: reactRouter(): client is …, which is not a directory. …`
683
+
684
+ ```text
685
+ TypeError: reactRouter(): client is build/clinet, which is not a directory. Pass the client build, build/client by default.
686
+ ```
687
+
688
+ **When:** at startup, `client` — `createServer`'s, `create`'s or
689
+ `reactRouter`'s — names a path that is missing or a file.
690
+
691
+ **Why:** the folder is read when the app is made, to declare a route per
692
+ top-level entry. A relative path is resolved against the process's
693
+ working directory, not the server file. Under the plugin, with no
694
+ `client` option, the folder is `build/client` resolved against the built
695
+ file, and is found wherever the process starts.
696
+
697
+ **Fix:** build first, leave `client` to the plugin, or pass the folder
698
+ relative to the file that names it:
699
+
700
+ ```ts
701
+ reactRouter(app, { build, client: new URL('./build/client', import.meta.url) });
702
+ ```
703
+
704
+ ### `TypeError: reactRouter(): … cannot be served at a path of its own name; rename it. …`
705
+
706
+ **When:** at startup, a top-level file or folder of the client build — a
707
+ copy of `public/` — has a name no route can carry: `a:b.txt` (a `:` starts
708
+ a parameter), `*x` (a `*` is a wildcard). The message ends with the core's
709
+ refusal, which says which.
710
+
711
+ A name a URL only encodes is fine: `my file.pdf` is served at
712
+ `/my%20file.pdf`, `café.png` at `/caf%C3%A9.png`, as a browser asks for
713
+ them.
714
+
715
+ **Fix:** rename the file in `public/`, or move it into a folder: a file
716
+ inside a folder is served by that folder's `static` route, whatever its
717
+ name.
718
+
719
+ ### A "load more" lands on the route's `ErrorBoundary`
720
+
721
+ **When:** the loader throws (or throws a `Response`) for a request that has the cursor, and the page used `usePagedRows`: the whole route is replaced by its `ErrorBoundary` instead of showing the rows with a retry button.
722
+
723
+ **Why:** React Router sends the error of a fetcher's load to the route's boundary. `usePagedRows` only sees what the fetcher answers, so its `error` is `true` for an answer that is not a page, not for a throw.
724
+
725
+ **Fix:** wrap the read in `orFailed(after, run)` from `@softistx/alxia-react-router/lists`, which answers `{ failed: true }` for a request that has the cursor and rethrows otherwise (and rethrows a redirect):
726
+
727
+ ```ts
728
+ export function loader({ request }: Route.LoaderArgs) {
729
+ const url = new URL(request.url);
730
+ return orFailed(url.searchParams.get('after'), () => listUsers(url.searchParams));
731
+ }
732
+ ```
733
+
734
+ By hand, that is:
735
+
736
+ ```ts
737
+ export async function loader({ request }: Route.LoaderArgs) {
738
+ const url = new URL(request.url);
739
+ try {
740
+ return await listUsers(url.searchParams);
741
+ } catch (error) {
742
+ if (url.searchParams.has('after')) return { message: 'unavailable' };
743
+ throw error;
744
+ }
745
+ }
746
+ ```
747
+
748
+ The rows stay, `error` is `true`, and `loadMore` retries.
749
+
750
+ ### `useFetcherPromise: a newer call replaced this one before the fetcher answered` (or `… the component unmounted before the fetcher answered`)
751
+
752
+ **When:** the Promise `run(submit)` returned rejects with a `FetcherPromiseAborted` instead of the action's answer.
753
+
754
+ **Why:** `'superseded'`: `run` was called again while the first call was still waiting (a double click), so only the newer call gets the answer. `'unmounted'`: the component left before the fetcher answered.
755
+
756
+ **Fix:** disable the control while the Promise is pending, and tell the two cases from a refusal by the class:
757
+
758
+ ```ts
759
+ import { FetcherPromiseAborted } from '@softistx/alxia-react-router/fetcher';
760
+
761
+ try {
762
+ await run(() => post({ intent: 'delete', id }));
763
+ } catch (error) {
764
+ if (error instanceof FetcherPromiseAborted) return;
765
+ setError((error as Error).message); // the refusal's message
766
+ }
767
+ ```
768
+
769
+ ### `useFetcherPromise: the submission ended without a new answer`
770
+
771
+ **When:** the Promise `run(submit)` returned rejects with a `FetcherPromiseNoAnswer` (in earlier versions it stayed pending forever).
772
+
773
+ **Why:** the fetcher went busy and idle again, but the action answered `null`, `undefined` or the very data the fetcher already held, so there is no new answer to settle the call.
774
+
775
+ **Fix:** have the action answer a fresh object (`{ ok: true }`), or handle the class when "nothing to say" is a normal outcome:
776
+
777
+ ```ts
778
+ import { FetcherPromiseNoAnswer } from '@softistx/alxia-react-router/fetcher';
779
+
780
+ try {
781
+ await run(() => post({ intent: 'touch', id }));
782
+ } catch (error) {
783
+ if (!(error instanceof FetcherPromiseNoAnswer)) throw error;
784
+ }
785
+ ```
786
+
787
+ ### `useSectionSave`: the section never shows its refusal, or another section's save closes it
788
+
789
+ **When:** a section posts but its field errors and notice never appear, or saving one section ends the edit of another.
790
+
791
+ **Why:** the hook only reads an answer whose `intent` equals its own `intent`. An action that answers without the `intent` (a hand-written `{ ok: false }`) is ignored, and two sections given the same `intent` read each other's answers.
792
+
793
+ **Fix:** answer through `sectionAction(errors, language, intent, run, { fieldOf, isStale })` with the `intent` the client posted, and give each section its own name.
794
+
795
+ ```ts
796
+ const { intent, ...input } = (await jsonActions().readJson(request)) as { intent: string };
797
+ return sectionAction(apiErrors, 'en', intent, () => save(input), { fieldOf, isStale });
798
+ ```
799
+
800
+ ### A debounced load lands on the route's `ErrorBoundary`
801
+
802
+ **When:** the resource route behind `useDebouncedFetcher` throws (or throws a `Response`) and the whole page is replaced by its `ErrorBoundary` instead of showing the previous suggestions with a retry.
803
+
804
+ **Why:** React Router sends the error of a fetcher's load to the route's boundary. `useDebouncedFetcher` only sees what the fetcher answers, so a failure it can show with `retry` has to be an answer.
805
+
806
+ **Fix:** answer `{ failed: true }` instead of throwing, for example with `orFailed(q, run)` from `@softistx/alxia-react-router/lists` (any non-empty value as its first argument makes it answer `{ failed: true }` on an error), and pass `keep` so a failure is never shown as the previous answer:
807
+
808
+ ```ts
809
+ export function loader({ request }: Route.LoaderArgs) {
810
+ const q = new URL(request.url).searchParams.get('q');
811
+ return orFailed(q, () => suggest(q));
812
+ }
813
+ // in the component
814
+ const { data, retry } = useDebouncedFetcher<typeof loader>(typed, toUrl, {
815
+ keep: (answer) => !('failed' in answer),
816
+ });
817
+ ```
818
+
819
+ ### The client's files are served uncompressed
820
+
821
+ A response for a script, a stylesheet or an SVG has no `Content-Encoding`,
822
+ though the request sent `Accept-Encoding: br, gzip`.
823
+
824
+ **When:** the server answers from `build/client`, and no `.br` or `.gz`
825
+ sits beside the file.
826
+
827
+ **Why:** the server never compresses on a request: it serves the copies
828
+ `react-router build` writes. They are missing when `alxia({ precompress:
829
+ false })` is set, when the build did not go through `alxia()` (a
830
+ `build/client` copied from a build before the option, or made by another
831
+ tool), when the file is under 1 kB or not compressible (an image, say), or
832
+ when `createServer({ precompressed: false })` is set. A compressed copy that
833
+ is not smaller than the file is not written.
834
+
835
+ A single-page app (`ssr: false` in `react-router.config.ts`) has no alxia server: the plugin builds the service worker only and writes no copies, so whatever serves `build/client` has to compress it.
836
+
837
+ **Fix:** build with the plugin, and check the copies exist:
838
+
839
+ ```sh
840
+ bun run build && ls build/client/assets | grep -E '\.(br|gz)$'
841
+ curl -sI -H 'Accept-Encoding: br' http://localhost:3000/assets/entry.js | grep -i content-encoding
842
+ ```
843
+
844
+ ### `Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'none'"`
845
+
846
+ The browser's console prints it; the page renders on the server, then
847
+ never hydrates, and a `<Form>` does not post (`form-action 'none'`).
848
+
849
+ **When:** `@softistx/alxia-secure-headers` is used with its default policy.
850
+
851
+ **Why:** the default, `default-src 'none'; base-uri 'none'; form-action
852
+ 'none'; frame-ancestors 'none'`, suits an API. A page loads its bundles
853
+ from `/assets`, runs React Router's inline scripts, and posts forms.
854
+
855
+ **Fix:** use `pageHeaders` for the pages, a strict policy with a nonce per
856
+ request and no `'unsafe-inline'` in `script-src`, and `secureHeaders` without
857
+ a policy in `beforeAll` for the client's files
858
+ ([the recipe](guide/csp-nonce.md#1-the-headers-in-appserverts)); the entry
859
+ passes the nonce on ([guide](guide/csp-nonce.md#a-csp-nonce)):
860
+
861
+ ```ts
862
+ // app/server.ts
863
+ import { createServer } from '@softistx/alxia-react-router';
864
+ import { pageHeaders, secureHeaders } from '@softistx/alxia-secure-headers';
865
+
866
+ export default createServer({
867
+ beforeAll: (app) => app.use(secureHeaders({ contentSecurityPolicy: false })),
868
+ configure: (app) => app.use(pageHeaders({ https: true })),
869
+ });
870
+ ```
871
+
872
+ If you must write the policy by hand, give `secureHeaders` a
873
+ `contentSecurityPolicy` that names `script-src 'self'` and `nonce: true`
874
+ (the nonce is added to `script-src`), never `'unsafe-inline'` there.
875
+
876
+ ### `Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-…'"`
877
+
878
+ **When:** the root renders an `<InlineScript>` (a theme's boot script, say)
879
+ and the policy names a nonce.
880
+
881
+ **Why:** the script rendered with no `nonce` attribute, because
882
+ `useNonce()` found no nonce: the server render has no `<DocumentNonce>`
883
+ around the router (an entry of your own that does not provide it), so
884
+ `InlineScript` renders a bare `<script>`. The browser then refuses it, and
885
+ the page flashes the wrong theme.
886
+
887
+ **Fix:** wrap the router in the nonce `pageHeaders` (or `secureHeaders({ nonce: true })`)
888
+ made, in `entry.server.tsx`, or pass one to the script:
889
+
890
+ ```tsx
891
+ // app/entry.server.tsx
892
+ import { nonceOf } from '@softistx/alxia-react-router';
893
+ import { DocumentNonce } from '@softistx/alxia-react-router/document';
894
+
895
+ return (
896
+ <DocumentNonce nonce={nonceOf(loadContext)}>
897
+ <ServerRouter context={routerContext} url={request.url} />
898
+ </DocumentNonce>
899
+ );
900
+ ```
901
+
902
+ or, for one script, `<InlineScript code={THEME_BOOT} nonce={nonce} />`.
903
+
904
+ Check the response: `curl -s -A 'Mozilla/5.0 Chrome/130' http://localhost:5173/ | grep -o '<script[^>]*>'`
905
+ should show `nonce="…"` on the boot script too
906
+ ([guide](guide/document.md#the-nonce-on-the-server)).
907
+
908
+ ### `A tree hydrated but some attributes of the server rendered HTML didn't match the client properties`
909
+
910
+ **When:** the page hydrates, and the warning names `<html>` with a `class`
911
+ or `style` the server did not render.
912
+
913
+ **Why:** a boot script (a theme's) sets `class` and `style` on `<html>`
914
+ before React hydrates, so the DOM no longer equals the server's HTML.
915
+
916
+ **Fix:** keep `suppressHydrationWarning` on `<html>`. It silences that
917
+ element's own attributes only, not its children:
918
+
919
+ ```tsx
920
+ // app/root.tsx
921
+ <html lang="en" suppressHydrationWarning>
922
+ <head>
923
+ <InlineScript code={THEME_BOOT} />
924
+ </head>
925
+ <body>{children}</body>
926
+ </html>
927
+ ```
928
+
929
+ A warning on another element is a real mismatch: a `nonce` the browser hid
930
+ is read by `useNonce()` from the document, so never pass it from loader
931
+ data ([guide](guide/document.md#the-theme-boot-script)).
932
+
933
+ ### `A tree hydrated but some attributes of the server rendered HTML didn't match the client properties` on a `<style>` with a `nonce`
934
+
935
+ **When:** in development (`react-router dev`) with a CSP nonce, the console
936
+ warns that a tree hydrated but some attributes did not match, and the diff
937
+ shows `nonce="…"` on the `<style data-react-router-critical-css>` in `<head>`.
938
+
939
+ **Why:** React Router renders the critical CSS as a `<style nonce>`. The
940
+ server writes the nonce from `<ServerRouter nonce>`, the browser hides the
941
+ attribute, and `<Links />` has no nonce to render on the client. Unlike
942
+ `<Scripts>` and `<ScrollRestoration>`, `<Links>` does not suppress that
943
+ warning.
944
+
945
+ **Fix:** pass it the nonce `useNonce()` reads, on both sides:
946
+
947
+ ```tsx
948
+ // app/root.tsx
949
+ import { useNonce } from '@softistx/alxia-react-router/document';
950
+
951
+ export function Layout({ children }: { children: React.ReactNode }) {
952
+ const nonce = useNonce();
953
+ return (
954
+ <html lang="en">
955
+ <head>
956
+ <Links nonce={nonce} />
957
+ </head>
958
+ <body>{children}</body>
959
+ </html>
960
+ );
961
+ }
962
+ ```
963
+
964
+ `<Scripts>` and `<ScrollRestoration>` need nothing
965
+ ([guide](guide/document.md#what-react-router-renders)).
966
+
967
+ ### `useNonce()` is undefined on the server
968
+
969
+ **When:** the page's inline scripts or `<CspNonceMeta />` render with no
970
+ `nonce` attribute although `secureHeaders({ nonce: true })` set one, and
971
+ `useNonce()` returns `undefined` in the root.
972
+
973
+ **Why:** the server render has no `<DocumentNonce>` around the router. The
974
+ entry of `@softistx/alxia-react-router/entry` adds it; an entry of your own, such
975
+ as React Router's revealed one, does not, and `ServerRouter`'s own `nonce`
976
+ prop only reaches the scripts React Router writes.
977
+
978
+ **Fix:** re-export the package's entry, or wrap the router in your own:
979
+
980
+ ```tsx
981
+ // app/entry.server.tsx
982
+ export {
983
+ handleRequest as default,
984
+ streamTimeout,
985
+ } from '@softistx/alxia-react-router/entry';
986
+ ```
987
+
988
+ ```tsx
989
+ // An entry of your own
990
+ import { nonceOf } from '@softistx/alxia-react-router';
991
+ import { DocumentNonce } from '@softistx/alxia-react-router/document';
992
+
993
+ <DocumentNonce nonce={nonceOf(loadContext)}>
994
+ <ServerRouter context={routerContext} url={request.url} />
995
+ </DocumentNonce>;
996
+ ```
997
+
998
+ ([guide](guide/document.md#the-entry))
999
+
1000
+ ### `TypeError: InlineScript(): the code contains "</script" or "<!--", which ends or confuses the script element; escape it, such as "<\/script" inside a string`
1001
+
1002
+ **When:** a page renders an `<InlineScript code={…} />` whose code holds
1003
+ `</script` (in any case) or `<!--`.
1004
+
1005
+ **Why:** the code is written into the page unescaped. A `</script` ends the
1006
+ element early, so what follows is HTML, not script, and can be markup an
1007
+ attacker chose; a `<!--` makes the HTML parser treat the following
1008
+ `<script` as part of the script's text. A nonce does not help: it only says
1009
+ the script may run. The component refuses the code instead of rendering it.
1010
+
1011
+ **Fix:** keep the code a constant of the app and escape the sequence inside
1012
+ a string. The code that reaches `InlineScript` must contain `<\/`, which the
1013
+ browser's script reads as `</`, and which is written `"<\\/script"` in a
1014
+ source string literal:
1015
+
1016
+ ```tsx
1017
+ <InlineScript code={'document.title = "<\\/script>"'} />
1018
+ ```
1019
+
1020
+ Never build the code from user input; pass such a value through a `data-`
1021
+ attribute and read it from the script.
1022
+ ([guide](guide/document.md#the-theme-boot-script))
1023
+
1024
+ ### `TypeError: createPageLanguage(): the fallback … is not one of the languages; got ….`
1025
+
1026
+ ```text
1027
+ TypeError: createPageLanguage(): the fallback "de" is not one of the languages; got ["en","fr"].
1028
+ ```
1029
+
1030
+ **When:** the module that calls `createPageLanguage` loads.
1031
+
1032
+ **Why:** `fallback` is the language of a page whose root data gives none, so
1033
+ it must be one of `languages`. The usual cause is a fallback in another
1034
+ spelling (`en-US` for `en`), or a `languages` list built from a different
1035
+ source than the fallback.
1036
+
1037
+ **Fix:** name a language of the list:
1038
+
1039
+ ```ts
1040
+ createPageLanguage({ languages: ['en', 'fr'], fallback: 'en' });
1041
+ ```
1042
+
1043
+ ### `TypeError: signInFlow(): a second factor needs both the challenge cookie (sessionCookies({ challenge })) and attemptsLeft; without one, give neither.`
1044
+
1045
+ ```text
1046
+ TypeError: signInFlow(): a second factor needs both the challenge cookie (sessionCookies({ challenge })) and attemptsLeft; without one, give neither.
1047
+ ```
1048
+
1049
+ **When:** the module that calls `signInFlow` loads.
1050
+
1051
+ **Why:** a second factor is the challenge cookie (`sessionCookies({ challenge })`)
1052
+ and the `attemptsLeft` wording together. The flow got only one: cookies with
1053
+ a challenge and no `attemptsLeft`, or an `attemptsLeft` and cookies built
1054
+ without `challenge`. TypeScript refuses the first when the cookies are typed
1055
+ `SessionCookies<true>`; a set typed `SessionCookies<boolean>` (a `challenge`
1056
+ that may be `undefined`) or a call from JavaScript reaches this check.
1057
+
1058
+ **Fix:** give both, or neither:
1059
+
1060
+ ```ts
1061
+ // with a second factor
1062
+ const cookies = sessionCookies({ session: 'my-app_session', challenge: 'my-app_challenge', secure });
1063
+ signInFlow({ cookies, errors, json, revoke, attemptsLeft });
1064
+
1065
+ // without one
1066
+ const plain = sessionCookies({ session: 'my-app_session', secure });
1067
+ signInFlow({ cookies: plain, errors, json, revoke });
1068
+ ```
1069
+
1070
+ ### The error page shows in the fallback language
1071
+
1072
+ **When:** on an error document, the root's `<html lang>` or text shows the
1073
+ fallback language although the visitor uses another.
1074
+
1075
+ **Why:** a child route's error keeps the root's loader data. React Router
1076
+ keeps `loaderData` for every loader that succeeded, so
1077
+ `useRouteLoaderData('root')` still has it in `Layout` and `ErrorBoundary`.
1078
+ The data is missing in only three cases:
1079
+
1080
+ - the URL matches no route, which is a 404 that runs no loader at all, the
1081
+ root's included;
1082
+ - the root's own loader threw;
1083
+ - a route's middleware threw (an access gate): React Router skips every
1084
+ loader and renders the root's error boundary.
1085
+
1086
+ With no data, `pageLanguage(undefined)` has no language to read. In the
1087
+ browser it keeps the last language it saw and the one picked with
1088
+ `chooseLanguage`, else reads `<html lang>`, which the server rendered.
1089
+
1090
+ **Fix, 404:** add a splat route whose loader throws a 404, so the URL
1091
+ matches and the root loader runs:
1092
+
1093
+ ```ts
1094
+ // app/routes.ts: add it last in your route config
1095
+ import { route } from '@react-router/dev/routes';
1096
+
1097
+ route('*', 'routes/not-found.tsx');
1098
+ ```
1099
+
1100
+ ```ts
1101
+ // app/routes/not-found.tsx
1102
+ import { data } from 'react-router';
1103
+
1104
+ export const loader = () => {
1105
+ throw data(null, { status: 404 });
1106
+ };
1107
+ ```
1108
+
1109
+ **Fix, middleware:** none is needed from the package's entry
1110
+ (`@softistx/alxia-react-router/entry`, or `createEntry()`): it puts `{ language }`
1111
+ from alxia's context (`@softistx/alxia-language`) in the root's data for the server
1112
+ render, and the browser reads `<html lang>`. An entry of your own does the
1113
+ same by writing `{ language: alxiaOf(loadContext).language }` into
1114
+ `routerContext.staticHandlerContext.loaderData.root` when it is missing;
1115
+ `createEntry({ rootData })` gives the root other data.
1116
+
1117
+ **Fix, root loader:** keep the root loader to `{ language: alxia.language }`,
1118
+ with nothing fallible in it. Load fallible data in child routes, or catch it
1119
+ and return it as a field.
1120
+
1121
+ **Fix, client:** none is needed: a failed client navigation keeps the last
1122
+ language through `pageLanguage`, and a document the server rendered as an
1123
+ error reads `<html lang>`.
1124
+
1125
+ ### `Error: You must render this element inside a <HydratedRouter> element`
1126
+
1127
+ **When:** under `react-router dev` or after `react-router build`, every page
1128
+ answers "Unexpected Server Error" with this message, once
1129
+ `entry.server.tsx` re-exports `@softistx/alxia-react-router/entry`.
1130
+
1131
+ **Why:** the server holds two copies of `react-router`: the one that
1132
+ renders `ServerRouter` in the entry, and the one `<Links>` and `<Scripts>`
1133
+ in the root read. They share no context. `alxia()` from
1134
+ `@softistx/alxia-react-router/vite` keeps them to one (it inlines `/entry` and
1135
+ `/document`, by an alias in dev and in the build, so they import the app's
1136
+ `react-router`). The message means `@softistx/alxia-react-router` is listed in
1137
+ `ssr.external` and `alxia()` is not in use.
1138
+
1139
+ **Fix:** add `alxia()` to `vite.config.ts` beside `reactRouter()`, or list
1140
+ `@softistx/alxia-react-router` in `ssr.noExternal` and remove it from
1141
+ `ssr.external`.
1142
+
1143
+ ### `alxia-react-router: … already exists, and reveal leaves it as it is. Run alxia-react-router reveal --force to overwrite it.`
1144
+
1145
+ ```text
1146
+ alxia-react-router: app/server.ts already exists, and reveal leaves it as it is. Run alxia-react-router reveal --force to overwrite it.
1147
+ ```
1148
+
1149
+ **When:** `bunx alxia-react-router reveal` finds a server file where it
1150
+ would write one: `app/server.ts`, or the file `alxia({ entry })` names. It
1151
+ exits 1 and writes nothing.
1152
+
1153
+ **Why:** that file is the app's server, customised or not; reveal never
1154
+ replaces it unasked.
1155
+
1156
+ **Fix:** keep it, or overwrite it with the default server, its options
1157
+ commented:
1158
+
1159
+ ```sh
1160
+ bunx alxia-react-router reveal --force
1161
+ ```
1162
+
1163
+ ### `alxia-react-router: no vite.config.ts in …. Run reveal from the app's root, beside vite.config.ts.`
1164
+
1165
+ **When:** `bunx alxia-react-router reveal` runs in a folder with no
1166
+ `vite.config.ts` (nor `.mts`, `.cts`, `.js`, `.mjs` or `.cjs`): a
1167
+ subfolder of the app, or another project.
1168
+
1169
+ **Why:** reveal reads where to write from the app's `vite.config.ts`,
1170
+ `alxia({ entry })`, and writes relative to it.
1171
+
1172
+ **Fix:** `cd` to the folder that holds `vite.config.ts`, and run it there.
1173
+
1174
+ ### `alxia-react-router: … gives alxia() an entry reveal cannot read. …`
1175
+
1176
+ ```text
1177
+ alxia-react-router: vite.config.ts gives alxia() an entry reveal cannot read. Write it as a string literal, alxia({ entry: 'app/server.ts' }), and run reveal again.
1178
+ ```
1179
+
1180
+ **When:** `vite.config.ts` passes `alxia()` an `entry` that is not a string
1181
+ literal: a constant, a template with `${…}`, a call. Reveal exits 1 and
1182
+ writes nothing.
1183
+
1184
+ **Why:** reveal reads the config as text, cheaply, and does not run it.
1185
+ Guessing `app/server.ts` would write a file the plugin does not load.
1186
+
1187
+ **Fix:** write the path as a literal, run reveal, then compute it again if
1188
+ you need to:
1189
+
1190
+ ```ts
1191
+ // vite.config.ts
1192
+ import { alxia } from '@softistx/alxia-react-router/vite';
1193
+ import { reactRouter } from '@react-router/dev/vite';
1194
+ import { defineConfig } from 'vite';
1195
+
1196
+ export default defineConfig({ plugins: [reactRouter(), alxia({ entry: 'server/main.ts' })] });
1197
+ ```
1198
+
1199
+ ### `alxia-react-router: … computes appDirectory, which reveal cannot read. …`
1200
+
1201
+ ```text
1202
+ alxia-react-router: react-router.config.ts computes appDirectory, which reveal cannot read. Write it as a string literal, appDirectory: 'app', and run reveal again.
1203
+ ```
1204
+
1205
+ **When:** `react-router.config.ts` sets `appDirectory` to something other
1206
+ than a string literal, and `vite.config.ts` names no `entry`. Reveal exits
1207
+ 1 and writes nothing.
1208
+
1209
+ **Why:** the same as above: reveal does not run the config, and `app/`
1210
+ might not be the folder the plugin reads.
1211
+
1212
+ **Fix:** write `appDirectory` as a literal for the time of the reveal, or
1213
+ name the file in `vite.config.ts`, `alxia({ entry: 'src/server.ts' })`.
1214
+
1215
+ ### `alxia-react-router: unknown command ….`
1216
+
1217
+ **When:** the bin is given a command other than `reveal`, such as
1218
+ `bunx alxia-react-router reveal-server`. It prints its usage and exits 1.
1219
+
1220
+ **Fix:** `bunx alxia-react-router reveal`, or `--help` for the usage.
1221
+
1222
+ ### `alxia-react-router: unknown option … for reveal.`
1223
+
1224
+ **When:** `reveal` is given an option other than `--force` or `--help`,
1225
+ such as react-router-hono-server's `reveal file` or `reveal folder`. It
1226
+ prints its usage and exits 1.
1227
+
1228
+ **Fix:** `bunx alxia-react-router reveal` writes the one server file the
1229
+ plugin reads. For a server in a folder of its own, name it first,
1230
+ `alxia({ entry: 'app/server/index.ts' })`, then run `reveal`: it writes
1231
+ there.
1232
+
1233
+ ### `error: GET https://registry.npmjs.org/alxia-react-router - 404`
1234
+
1235
+ **When:** `bunx alxia-react-router reveal` runs in a project where
1236
+ `@softistx/alxia-react-router` is not installed.
1237
+
1238
+ **Why:** `bunx` looks for the bin in `node_modules/.bin`, then for an npm
1239
+ package of the bin's name. The bin is `@softistx/alxia-react-router`'s, and no
1240
+ package is named `alxia-react-router`.
1241
+
1242
+ **Fix:** install the package, then run the bin:
1243
+
1244
+ ```sh
1245
+ bun add @softistx/alxia @softistx/alxia-react-router
1246
+ bunx alxia-react-router reveal
1247
+ ```
1248
+
1249
+ ### `alxia-react-router: build/server/index.js does not exist. Run react-router build before vite preview.`
1250
+
1251
+ With another `buildDirectory` or `serverBuildFile`, the message names
1252
+ that file.
1253
+
1254
+ Under `vite preview`, every request is a 500 with this text, and Vite's
1255
+ terminal prints it.
1256
+
1257
+ **When:** the preview server starts before a build, or after
1258
+ `build/server/index.js` was removed.
1259
+
1260
+ **Why:** under the plugin, the preview serves the built server, and there
1261
+ is none yet.
1262
+
1263
+ **Fix:** build, then preview:
1264
+
1265
+ ```sh
1266
+ bun run build
1267
+ bunx --bun vite preview
1268
+ ```
1269
+
1270
+ The next request after the build loads it, with no restart.
1271
+
1272
+ ### `alxia-react-router: build/server/index.js is not alxia's server: its default export has no fetch. …`
1273
+
1274
+ With another `buildDirectory` or `serverBuildFile`, the message names
1275
+ that file.
1276
+
1277
+ ```text
1278
+ alxia-react-router: build/server/index.js is not alxia's server: its default export has no fetch. Build it with alxia() in vite.config.ts's plugins, then run vite preview again.
1279
+ ```
1280
+
1281
+ **When:** under `vite preview`, the build in `build/` was made without
1282
+ `alxia()`: before the plugin was added, or with another Vite config.
1283
+
1284
+ **Why:** React Router's own server build exports the routes and no app.
1285
+ The plugin hands each request to the default export's `fetch`, which only
1286
+ a build made with the plugin has.
1287
+
1288
+ **Fix:** add `alxia()` to `vite.config.ts`'s plugins, run `bun run build`,
1289
+ then restart `vite preview`: a build already loaded is not read again.
1290
+
1291
+ ### `warn: incorrect peer dependency "typescript@5.9.3"`
1292
+
1293
+ `bun add @softistx/alxia @softistx/alxia-react-router` prints it in the official
1294
+ template.
1295
+
1296
+ **Why:** the template ships TypeScript 5.9, and alxia's packages declare
1297
+ `typescript` 6 or 7 as a peer: their declarations are tested with those.
1298
+ The template's own code, with a server file and typed loaders, typechecks
1299
+ under 5.9 too.
1300
+
1301
+ **Fix:** none is needed to run. To silence it, and typecheck with what
1302
+ alxia is tested on:
1303
+
1304
+ ```sh
1305
+ bun add -d typescript@^6
1306
+ ```
1307
+
1308
+ ### `Module "…" has been externalized for browser compatibility, imported by "…"`
1309
+
1310
+ `react-router build` warns it while building the client, for
1311
+ `Module "bun:sqlite"` or `Module "bun"`. What follows depends on Vite:
1312
+
1313
+ - **Vite 7** then fails the build:
1314
+
1315
+ ```
1316
+ RollupError: app/routes/todos.tsx (1:9): "Database" is not exported by "__vite-browser-external", imported by "app/routes/todos.tsx".
1317
+ ```
1318
+
1319
+ - **Vite 8** builds, and the page fails in the browser instead, with
1320
+ `TypeError: … is not a constructor` or `… is not a function` once it
1321
+ hydrates.
1322
+
1323
+ **Why:** a route module imports one of Bun's modules, `bun` or `bun:*`,
1324
+ and uses it outside its `loader` and `action`, in the component or at the
1325
+ module's top level. React Router keeps that code in the client build, for
1326
+ the browser, which has no such module. The server build leaves Bun's
1327
+ modules external ([Built for Bun](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/how-it-works.md#built-for-bun));
1328
+ the client build cannot.
1329
+
1330
+ **Fix:** use them only in the server's code: in `loader` and `action`, or
1331
+ in a `.server.ts` module, which React Router keeps out of the client.
1332
+
1333
+ ```ts
1334
+ // app/db.server.ts
1335
+ import { Database } from 'bun:sqlite';
1336
+
1337
+ export const db = new Database(':memory:');
1338
+ ```
1339
+
1340
+ ```tsx
1341
+ // app/routes/todos.tsx
1342
+ import { db } from '../db.server';
1343
+
1344
+ export function loader() {
1345
+ return { version: db.query('select sqlite_version() as v').get() };
1346
+ }
1347
+ ```
1348
+
1349
+ ### `error: lockfile had changes, but lockfile is frozen`
1350
+
1351
+ `docker build` stops at `RUN bun install --frozen-lockfile`, followed by
1352
+ `note: try re-running without --frozen-lockfile and commit the updated lockfile`.
1353
+
1354
+ **Why:** the `Dockerfile` installs exactly what `bun.lock` records, and
1355
+ `package.json` asks for something it does not: a dependency added or
1356
+ changed by hand, without `bun install`.
1357
+
1358
+ **Fix:** update the lockfile, commit it, and build again:
1359
+
1360
+ ```sh
1361
+ bun install
1362
+ git add bun.lock
1363
+ docker build -t my-app .
1364
+ ```
1365
+
1366
+ ### `EACCES: permission denied, open '/app/…'`
1367
+
1368
+ The container starts, then a write fails: `Bun.write` gives this, and
1369
+ `new Database('/app/data.sqlite')` gives
1370
+ `SQLiteError: unable to open database file`.
1371
+
1372
+ **Why:** the `Dockerfile` runs the server as the image's `bun` user, not
1373
+ root, and `/app` is root's: the user reads the build and cannot write
1374
+ beside it.
1375
+
1376
+ **Fix:** write to a directory the user owns, a volume for what must
1377
+ outlive the container:
1378
+
1379
+ ```dockerfile
1380
+ # Dockerfile, before USER bun
1381
+ RUN mkdir /data && chown bun:bun /data
1382
+ VOLUME /data
1383
+ ```
1384
+
1385
+ ```ts
1386
+ const db = new Database('/data/app.sqlite');
1387
+ ```
1388
+
1389
+ ### `error: Cannot find package '…' from '/app/build/server/index.js'`
1390
+
1391
+ `bun build/server/index.js`, in the container or from a copy of `build/`
1392
+ alone, stops at startup. For a package loaded with `require`, the message
1393
+ can read `Cannot find module '…'`. Or it starts, and a request fails with
1394
+ `ENOENT: no such file or directory, open '/app/build/…'`.
1395
+
1396
+ **When:** the image holds `build/` alone, as the template's `Dockerfile`
1397
+ copies it, and the server imports a package that is not inside
1398
+ `build/server/index.js`:
1399
+
1400
+ - the app keeps it external with `ssr.external`, and the image has no
1401
+ `node_modules`;
1402
+ - or the build bundled it, but it reads a file of its own folder at
1403
+ runtime (`new URL('./data.json', import.meta.url)`), or loads a native
1404
+ addon (a `.node` file), neither of which bundling carries along.
1405
+
1406
+ The image runs `bun --no-install`: without the flag, Bun finds no
1407
+ `node_modules` and fetches the missing package from npm at startup, at
1408
+ whatever version npm has, instead of failing.
1409
+
1410
+ **Why:** under `react-router build` the plugin bundles every package into
1411
+ `build/server/index.js` ([Self-contained](guide/how-it-works.md#self-contained)), so
1412
+ the image needs no `node_modules`. What stays outside the file must be
1413
+ installed beside it.
1414
+
1415
+ **Fix:** keep the package external, and give the image the production
1416
+ dependencies:
1417
+
1418
+ ```ts
1419
+ // vite.config.ts
1420
+ export default defineConfig({
1421
+ ssr: { external: ['sharp'] },
1422
+ plugins: [reactRouter(), alxia()],
1423
+ });
1424
+ ```
1425
+
1426
+ ```dockerfile
1427
+ # Dockerfile, before the build stage
1428
+ FROM oven/bun:1 AS production-dependencies
1429
+ WORKDIR /app
1430
+ COPY package.json bun.lock* bunfig.toml* ./
1431
+ RUN bun install --frozen-lockfile --production
1432
+
1433
+ # Dockerfile, in the final stage, beside build/
1434
+ COPY --from=production-dependencies /app/node_modules ./node_modules
1435
+ ```
1436
+
1437
+ `grep '^import' build/server/index.js` lists what the build still
1438
+ imports: `node:*`, `bun`, `bun:*` and the packages `ssr.external` names.
1439
+
1440
+ The image runs on `oven/bun:1-alpine`, whose C library is musl. A native
1441
+ addon built for glibc alone then stops it with
1442
+ `… is linked against glibc (DT_NEEDED …), but this Bun build uses musl.`:
1443
+ put the final stage back on `oven/bun:1`
1444
+ ([`@softistx/alxia-create`'s troubleshooting](https://github.com/softistx/alxia/blob/develop/packages/create/docs/troubleshooting.md#error--is-linked-against-glibc-dt_needed-libmso6-but-this-bun-build-uses-musl)).
1445
+
1446
+ ### `TypeError: defineWorkerContract(): cachePrefix must be a non-empty name, …`
1447
+
1448
+ The full message is `defineWorkerContract(): cachePrefix must be a non-empty
1449
+ name, such as 'my-app'; got ''.`, or `… must not end with '-', which the
1450
+ contract adds; got 'my-app-'. Use 'my-app'.`
1451
+
1452
+ **Why:** every cache name is `<prefix>-<kind>-<version>`, and the worker
1453
+ deletes the caches shaped `<prefix>-<kind>-<version>`. An empty prefix would own
1454
+ every cache of the origin, and a trailing dash would be doubled.
1455
+
1456
+ **Fix:** pass the app's own name, without the dash:
1457
+
1458
+ ```ts
1459
+ import { defineWorkerContract } from '@softistx/alxia-react-router/pwa';
1460
+
1461
+ export const workerContract = defineWorkerContract({ cachePrefix: 'my-app' });
1462
+ ```
1463
+
1464
+ ### `TypeError: defineWorkerContract(): cacheVersion must be a non-empty name without '-', …`
1465
+
1466
+ The full message is `defineWorkerContract(): cacheVersion must be a
1467
+ non-empty name without '-', such as 'v2'; got 'v1-beta'.`
1468
+
1469
+ **Why:** every cache name is `<prefix>-<kind>-<version>`, and the contract
1470
+ tells a version from the rest of the name by its dashes. A version with a `-`
1471
+ (or an empty one) would make the name ambiguous.
1472
+
1473
+ **Fix:** use a name with no dash, such as `'v2'` or `'2026'`:
1474
+
1475
+ ```ts
1476
+ import { defineWorkerContract } from '@softistx/alxia-react-router/pwa';
1477
+
1478
+ export const workerContract = defineWorkerContract({
1479
+ cachePrefix: 'my-app',
1480
+ cacheVersion: 'v2',
1481
+ });
1482
+ ```
1483
+
1484
+ ### `parseBrowserManifest(): not React Router's browser manifest …`
1485
+
1486
+ The full message ends with `(build/client/assets/manifest-*.js).`
1487
+
1488
+ **Why:** the source holds no `{ … }` object. The build script read another
1489
+ file, an empty one, or the build has not run.
1490
+
1491
+ **Fix:** run `react-router build` first, then read the file named
1492
+ `manifest-<hash>.js` in `build/client/assets`, not the server's manifest:
1493
+
1494
+ ```ts
1495
+ import { readdirSync, readFileSync } from 'node:fs';
1496
+ import { parseBrowserManifest } from '@softistx/alxia-react-router/pwa';
1497
+
1498
+ const assets = 'build/client/assets';
1499
+ const file = readdirSync(assets).find((name) => /^manifest-.*\.js$/.test(name));
1500
+ if (!file) throw new Error('Run react-router build first.');
1501
+ export const manifest = parseBrowserManifest(readFileSync(`${assets}/${file}`, 'utf8'));
1502
+ ```
1503
+
1504
+ ### `error: Cannot find package 'react' from '…/@softistx/alxia-react-router/dist/pwa/react/index.js'`
1505
+
1506
+ **Why:** `@softistx/alxia-react-router/pwa/react` imports `react`, an optional peer of
1507
+ the package, so nothing installs it for you. An app with no `react` does not
1508
+ need the subpath; a build script or the worker importing it by mistake meets
1509
+ this message too.
1510
+
1511
+ **Fix:** add `react` where the page is built (`bun add react`), and import
1512
+ `/pwa/react` from the page alone. The worker and a build script import
1513
+ `@softistx/alxia-react-router/pwa`, which imports nothing.
1514
+
1515
+ ### `error: Cannot find package 'isbot' from '…/@softistx/alxia-react-router/dist/entry/index.js'`
1516
+
1517
+ **When:** a request with a user agent reaches `entry.server.tsx` re-exporting
1518
+ `@softistx/alxia-react-router/entry` (or a `createEntry()` with no `isBot` option).
1519
+
1520
+ ```text
1521
+ error: Cannot find package 'isbot' from '/app/node_modules/@softistx/alxia-react-router/dist/entry/index.js'
1522
+ ```
1523
+
1524
+ **Why:** with no `isBot` option, `/entry` asks `isbot` whether a request
1525
+ comes from a crawler, which then gets the whole page, and imports it on the
1526
+ first request that needs it. `isbot` and `react-dom` are optional peers of
1527
+ the package, so nothing installs them for you. React Router's templates
1528
+ install both; an app made another way may not.
1529
+
1530
+ **Fix:** add them where the server is built and run:
1531
+
1532
+ ```sh
1533
+ bun add isbot react-dom
1534
+ ```
1535
+
1536
+ Or give the `isBot` option, which replaces the check: `isbot` is then never
1537
+ imported, and only `react-dom` is needed.
1538
+
1539
+ ### `error: Cannot find package '@softistx/alxia-proxy' from '…/@softistx/alxia-react-router/dist/mcp/index.js'`
1540
+
1541
+ **When:** the server starts with `mcpRelay` imported from `@softistx/alxia-react-router/mcp`.
1542
+
1543
+ ```text
1544
+ error: Cannot find package '@softistx/alxia-proxy' from '/app/node_modules/@softistx/alxia-react-router/dist/mcp/index.js'
1545
+ ```
1546
+
1547
+ **Why:** `/mcp` relays through `@softistx/alxia-proxy`, an optional peer of the package, so nothing installs it for you. Apps that never import `/mcp` do not need it.
1548
+
1549
+ **Fix:** add it where the server is built and run:
1550
+
1551
+ ```sh
1552
+ bun add @softistx/alxia-proxy
1553
+ ```
1554
+
1555
+ ### `TypeError: proxy(): the target must be an absolute URL, http:// or https://; got "…"`
1556
+
1557
+ **When:** the server starts, and `mcpRelay`'s `api` is not an absolute `http://` or `https://` URL (a path, a host with no scheme, an empty string from a missing environment variable).
1558
+
1559
+ **Why:** the relay builds its forwarders when `mcpRelay` is called, and `@softistx/alxia-proxy` refuses the target then.
1560
+
1561
+ **Fix:** give the API's origin with its scheme:
1562
+
1563
+ ```ts
1564
+ mcpRelay({ api: 'https://api.example.com', secret })
1565
+ ```
1566
+
1567
+ ### `TypeError: proxy(): timeout must be a number of milliseconds above 0; got …`
1568
+
1569
+ **When:** the server starts, and `mcpRelay`'s `timeout` is `0`, negative, `NaN` or not a finite number.
1570
+
1571
+ **Fix:** pass a positive number of milliseconds, or leave `timeout` out for the 60 000 ms default.
1572
+
1573
+ ### `startWorker(): no precache list. …`
1574
+
1575
+ **Why:** the full message ends "Build this worker with `alxia()` from
1576
+ `@softistx/alxia-react-router/vite` (`app/service-worker.ts`) or `buildWorker()` from
1577
+ `@softistx/alxia-react-router/pwa/build`, which write it in." `startWorker` precaches
1578
+ the list the build defines in the bundle (`globalThis.__ALXIA_PRECACHE__`);
1579
+ a worker bundled by anything else has none, and the page would install a
1580
+ worker that precaches nothing.
1581
+
1582
+ **Fix:** either build the worker with the build that writes the list
1583
+ (`alxia()` or `buildWorker()`), or pass the list yourself, which works for a
1584
+ worker bundled any other way:
1585
+
1586
+ ```ts
1587
+ startWorker({
1588
+ contract,
1589
+ precache: [{ url: '/offline.html', revision: 'v1' }],
1590
+ });
1591
+ ```
1592
+
1593
+ `precache` wins over the list the build wrote. A bundle of your own may
1594
+ instead define `globalThis.__ALXIA_PRECACHE__`.
1595
+
1596
+ ### `TypeError: startWorker(): contract is required: …`
1597
+
1598
+ **Why:** the full message continues "pass `defineWorkerContract({ cachePrefix })`
1599
+ from `@softistx/alxia-react-router/pwa`." The worker's cache names, its offline page
1600
+ and its URL come from the contract the page shares, so there is no default.
1601
+
1602
+ **Fix:**
1603
+
1604
+ ```ts
1605
+ // file: app/service-worker.ts
1606
+ import { defineWorkerContract } from '@softistx/alxia-react-router/pwa';
1607
+ import { startWorker } from '@softistx/alxia-react-router/pwa/worker';
1608
+
1609
+ startWorker({ contract: defineWorkerContract({ cachePrefix: 'my-app' }) });
1610
+ ```
1611
+
1612
+ ### `error: Could not resolve: "workbox-core". Maybe you need to "bun install"?`
1613
+
1614
+ **Why:** `@softistx/alxia-react-router/pwa/worker` imports six `workbox-*` packages,
1615
+ optional peers of the package, so nothing installs them for you. They are
1616
+ bundled into the worker, never loaded at run time.
1617
+
1618
+ **Fix:** add them as development dependencies:
1619
+
1620
+ ```sh
1621
+ bun add -d workbox-core workbox-expiration workbox-navigation-preload \
1622
+ workbox-precaching workbox-routing workbox-strategies
1623
+ ```
1624
+
1625
+ The `buildWorker()` messages below are the ones a script of your own sees.
1626
+ Under `alxia()` each of them begins with `alxia-react-router: `.
1627
+
1628
+ ### `buildWorker() runs on Bun: it is running on Node`
1629
+
1630
+ ```text
1631
+ buildWorker() runs on Bun: it is running on Node. Run it with bun, or run react-router build with bun --bun.
1632
+ ```
1633
+
1634
+ **When:** a script of your own calls `buildWorker()` and runs on Node. Under
1635
+ `alxia()` the check comes first and reads
1636
+ [`… is running on Node, and the worker is bundled by Bun.build`](#alxia-react-router--is-running-on-node-and-alxias-server-runs-on-bun-).
1637
+
1638
+ **Why:** the worker is bundled with `Bun.build`, which Node does not have.
1639
+
1640
+ **Fix:** run the script with `bun scripts/build-worker.ts`, or
1641
+ `react-router build` as `bun --bun react-router build`.
1642
+
1643
+ ### `buildWorker(): app/service-worker.ts does not exist.`
1644
+
1645
+ ```text
1646
+ buildWorker(): app/service-worker.ts does not exist.
1647
+ ```
1648
+
1649
+ **Why:** `file` is read from `root` (`process.cwd()` by default), not from the
1650
+ script's folder. Under `alxia()` the message begins
1651
+ `alxia-react-router: buildWorker(): …`.
1652
+
1653
+ **Fix:** pass the path relative to the project root, or pass `root`.
1654
+
1655
+ ### `buildWorker(): expected one React Router browser manifest`
1656
+
1657
+ ```text
1658
+ buildWorker(): expected one React Router browser manifest, build/client/assets/manifest-*.js, found 0. Run react-router build first.
1659
+ ```
1660
+
1661
+ The message ends `found 2` when two are left.
1662
+
1663
+ **Why:** the precache list is read from React Router's browser manifest,
1664
+ which `react-router build` writes. None means the build did not run, or
1665
+ `client` is wrong. Two mean a stale build folder.
1666
+
1667
+ **Fix:** run `react-router build` first, check `client`, and delete `build/`
1668
+ when two manifests are left.
1669
+
1670
+ ### `buildWorker(): build/client/offline.html does not exist`
1671
+
1672
+ ```text
1673
+ buildWorker(): build/client/offline.html does not exist. Add public/offline.html, or pass offline: false (`worker: { offline: false }` in alxia()), or pass the app's contract (`worker: { contract }` in alxia()).
1674
+ ```
1675
+
1676
+ **Why:** the offline page is precached by default and is read from the client
1677
+ build, where `public/offline.html` is copied. The build reads the contract's
1678
+ `offlineUrl` from the `contract` option, and the worker from the contract it
1679
+ is given: two objects can disagree.
1680
+
1681
+ **Fix:** add the page to `public/`, or pass `offline: false` for a worker with
1682
+ no offline page. If the contract's `offlineUrl` is another path, pass the same
1683
+ contract object to the build (`alxia({ worker: { contract } })`, or
1684
+ `buildWorker({ contract })`).
1685
+
1686
+ ### `buildWorker(): … is outside ….`
1687
+
1688
+ ```text
1689
+ buildWorker(): /../service-worker.js is outside /app/build/client.
1690
+ ```
1691
+
1692
+ **Why:** the contract's `serviceWorkerUrl` or `offlineUrl` is joined onto the
1693
+ client build, and the result leaves it, or is the client build itself (`/`).
1694
+ The build refuses to write or read a file there. It also refuses an absolute
1695
+ URL (`https://example.com/sw.js`), a protocol-relative one (`//host/sw.js`) and
1696
+ one that does not start with `/`, since none names a file of the build.
1697
+
1698
+ **Fix:** use a root-relative URL inside the site, such as
1699
+ `/service-worker.js`, in the contract.
1700
+
1701
+ ### `buildWorker(): Bun.build failed:`
1702
+
1703
+ ```text
1704
+ buildWorker(): Bun.build failed:
1705
+ ```
1706
+
1707
+ Bun's logs follow the message.
1708
+
1709
+ **Why:** the worker's source or one of its imports did not bundle: a missing
1710
+ `workbox-*` package, a wrong import path.
1711
+
1712
+ **Fix:** read the first log line. The six `workbox-*` packages are optional
1713
+ peers, installed as
1714
+ [`Could not resolve: "workbox-core"`](#error-could-not-resolve-workbox-core-maybe-you-need-to-bun-install)
1715
+ shows.
1716
+
1717
+ ### `Cross-site request refused`
1718
+
1719
+ **When:** an action calls `requireSameSite(request)` (a native form post), reads its body with `readJson` or `readInput` (from
1720
+ `jsonActions()`), or runs one of `/session`'s steps (`signInStep`,
1721
+ `readCodeInput`, `linkArgs`, `spendToken`, `landByLink`, `afterReset`,
1722
+ `requestLink`, the step-up's `request` and `confirm`, `landReplacing`,
1723
+ `revokeSession`, `signIn.guard`), and the page's post answers 403 with this
1724
+ text. The session steps refuse before they read the body.
1725
+
1726
+ **Why:** the request carried an `Origin` other than the app's own, or a
1727
+ `Sec-Fetch-Site` that is neither `same-origin` nor `none`. That is what a
1728
+ post from another site looks like, so it is refused before the body is read.
1729
+ The usual honest cause is that the app's origin is not the one the request
1730
+ reaches: see [Behind a TLS proxy every action answers 403](#behind-a-tls-proxy-every-action-answers-403). `requireSameSite(request, { origin })` takes the public origin like `jsonActions({ origin })`.
1731
+
1732
+ **Fix:** if the post comes from another site, nothing: the refusal is the
1733
+ point. If it comes from your own page, give `jsonActions` the origin your
1734
+ users see:
1735
+
1736
+ ```ts
1737
+ export const { readJson } = jsonActions({
1738
+ origin: 'https://app.example.com',
1739
+ });
1740
+ ```
1741
+
1742
+ ### `Expected a JSON body`
1743
+
1744
+ **When:** an action answers 415 with this text.
1745
+
1746
+ **Why:** `readJson` takes only `application/json`. A native form post
1747
+ (`application/x-www-form-urlencoded` or `multipart/form-data`), a
1748
+ `text/plain` body and a request with no content type are refused, since only
1749
+ JSON needs a preflight from another site.
1750
+
1751
+ **Fix:** post from `useJsonFetcher`, which sets the content type
1752
+ (`encType: 'application/json'`), or set `Content-Type: application/json` on
1753
+ your own `fetch`. For an action that a native form also posts to before the
1754
+ page hydrates, call `requireJsonPost(request)` first: it sends that post back
1755
+ to its page, which then posts JSON.
1756
+
1757
+ ```ts
1758
+ const { requireJsonPost, readJson } = jsonActions();
1759
+
1760
+ export async function action({ request }: Route.ActionArgs) {
1761
+ requireJsonPost(request);
1762
+ const body = await readJson(request);
1763
+ // …
1764
+ }
1765
+ ```
1766
+
1767
+ ### `Malformed JSON body`
1768
+
1769
+ **When:** an action answers 400 with this text.
1770
+
1771
+ **Why:** the request declared `application/json`, but `request.json()` could
1772
+ not parse the body: it is empty, truncated, or not JSON at all (a form's
1773
+ `FormData` posted with the JSON content type, for example).
1774
+
1775
+ **Fix:** post an object through `useJsonFetcher`'s `post(body)`, or
1776
+ `JSON.stringify` the body of your own `fetch`. Do not set the content type by
1777
+ hand on a `FormData` body.
1778
+
1779
+ ### `The form sent an input the API would refuse`
1780
+
1781
+ **When:** an action that reads its body with `readInput(request, schema)`
1782
+ answers 400 with this text.
1783
+
1784
+ **Why:** the body was JSON, but its `input` field did not pass the schema: it
1785
+ is missing, or one of the checks failed. `readInput` reads `{ input }`, not
1786
+ the whole body, and it answers a bare 400 on purpose: the schema is the API's
1787
+ own input, so a form that passed its own checks never gets here.
1788
+
1789
+ **Fix:** post `{ input: … }`, and make the form's checks the schema's. To see
1790
+ what the schema refused while you debug, call it yourself:
1791
+
1792
+ ```ts
1793
+ const body = (await readJson(request)) as { input?: unknown };
1794
+ const result = await schema['~standard'].validate(body.input);
1795
+ console.log(result.issues);
1796
+ ```
1797
+
1798
+ ### `alxia-react-router: the error catalogue (…) was not read`
1799
+
1800
+ **When:** the server logs this line (with the error after it, at the level of
1801
+ `log.error`) while a language's catalogue is read for the first time, and the
1802
+ refusals in that language read in the API's own words.
1803
+
1804
+ **Why:** the app's `read(language)` threw: the API was down, slow past its own
1805
+ timeout, or answered an error. The catalogue keeps no partial result. It tries
1806
+ again once `retryMs` (5 seconds by default) has passed since the failure, on
1807
+ the next request that asks for that language; one read is in flight at a time.
1808
+
1809
+ **Fix:** read the error that follows the line. Once the API answers, the next
1810
+ request after the delay reads the catalogue and the refusals are worded; no
1811
+ restart is needed. To see the calls, give `createErrorCatalogue` a `log`
1812
+ that records them.
1813
+
1814
+ ### `alxia-react-router: the error catalogue was not checked, keeping what is held`
1815
+
1816
+ **When:** the server logs this line (with the error after it) once a held
1817
+ catalogue is older than the TTL and the check of the versions failed.
1818
+
1819
+ **Why:** `versions()` threw. The catalogue keeps serving the messages it
1820
+ holds, which may be stale, and asks again after `retryMs` instead of after a
1821
+ whole TTL.
1822
+
1823
+ **Fix:** read the error that follows. Nothing to restart: when the API
1824
+ answers, the check goes on and re-reads the languages whose version moved.
1825
+ If it repeats while the API is up, check that `versions()` returns a version
1826
+ for every language in `languages`: a language missing from its answer is read
1827
+ again at each check.
1828
+
1829
+ ### `alxia-react-router: the error catalogue was not warmed`
1830
+
1831
+ **When:** the server logs this line at startup, after `warm()`.
1832
+
1833
+ **Why:** `warm()` reads every language without holding the boot back, and
1834
+ the promise it started rejected. The reads themselves report their failures
1835
+ (`the error catalogue (…) was not read`), so this line means something else
1836
+ threw.
1837
+
1838
+ **Fix:** read the error that follows. The first request that asks for a
1839
+ language reads it anyway, so the server is not left without a catalogue.
1840
+
1841
+ ### `alxia-react-router: ttlMs threw, using retryMs`
1842
+
1843
+ **When:** the server logs this line (with the error after it) each time the
1844
+ catalogue reads its TTL and the `ttlMs` getter throws.
1845
+
1846
+ **Why:** `ttlMs` is a getter of the app's, such as one that reads a setting,
1847
+ and it threw. The catalogue does not let it break a request: it uses
1848
+ `retryMs` as the TTL for that read, so the held messages are still served
1849
+ and the versions are checked again soon.
1850
+
1851
+ **Fix:** read the error that follows and fix the getter, or pass a number.
1852
+
1853
+ ```ts
1854
+ const catalogue = createErrorCatalogue({
1855
+ // …
1856
+ ttlMs: () => settings.catalogueTtlMs ?? 60_000,
1857
+ });
1858
+ ```
1859
+
1860
+ ### `alxia-react-router: ttlMs is not a duration, using retryMs`
1861
+
1862
+ **When:** the server logs this line each time the catalogue reads its TTL and
1863
+ `ttlMs` is not a finite number of at least 0: `NaN`, `Infinity`, a negative
1864
+ number, or a value that is not a number, such as the string a setting
1865
+ returned.
1866
+
1867
+ **Why:** a TTL that is not a duration would never expire a held catalogue
1868
+ (`Infinity`) or make every comparison false (`NaN`). The catalogue treats it
1869
+ like a getter that threw: it uses `retryMs` for that read.
1870
+
1871
+ **Fix:** pass a number of milliseconds, converted where the setting is read:
1872
+
1873
+ ```ts
1874
+ const catalogue = createErrorCatalogue({
1875
+ // …
1876
+ ttlMs: () => Number(process.env.CATALOGUE_TTL_MS ?? 60_000),
1877
+ });
1878
+ ```
1879
+
1880
+ ### `TypeError: createErrorCatalogue(): needs at least one language.`
1881
+
1882
+ **When:** the server starts, or the module that calls `createErrorCatalogue`
1883
+ is imported.
1884
+
1885
+ **Why:** `languages` is empty, usually a list built from an environment
1886
+ variable or a config that was not set.
1887
+
1888
+ **Fix:** pass the languages the app serves, the same list the page's
1889
+ translator knows:
1890
+
1891
+ ```ts
1892
+ const catalogue = createErrorCatalogue({
1893
+ messages: apiMessages,
1894
+ languages: ['en', 'fr'],
1895
+ // …
1896
+ });
1897
+ ```
1898
+
1899
+ ### `<api>: <operation> (request <id>) answered <status> <code>`
1900
+
1901
+ Logged by `apiCallFailure` (a warning for a 4xx, an error for a 5xx), after the
1902
+ `api` the app gave it, when the
1903
+ API refused a call with a GraphQL body, or answered a status that is passed
1904
+ through, such as a 404, which has no `<code>`. For example
1905
+ `my-api https://api.example.com/graphql: Todos (request r-1) answered 403 todos.errors.forbidden`.
1906
+
1907
+ **Why:** the API answered, and refused: `<status>` and `<code>` are the
1908
+ `ApiError`'s. A 4xx is expected (a forbidden page, a missing record), which is
1909
+ why it is a warning. The `(request …)` part is there only if the API sent an
1910
+ `x-request-id` and your code passed it as `requestId`; without it the line
1911
+ carries no id and an error page can show none.
1912
+
1913
+ **Fix:** nothing to fix in the package. To find the API's own log line, search
1914
+ for the id. To get the id in the line, pass `requestId: requestIdOf(response)`
1915
+ from the `fetch` the client calls:
1916
+
1917
+ ```ts
1918
+ import { apiCallFailure, requestIdOf } from '@softistx/alxia-react-router/errors';
1919
+
1920
+ let requestId: string | undefined;
1921
+ const send = async (request: Request) => {
1922
+ const response = await fetch(request);
1923
+ requestId = requestIdOf(response);
1924
+ return response;
1925
+ };
1926
+
1927
+ export const failed = (error: unknown) =>
1928
+ apiCallFailure(error, { api: 'my-api', requestId });
1929
+ ```
1930
+
1931
+ ### `<api>: <operation> (request <id>) answered <status> without GraphQL`
1932
+
1933
+ Logged as an error by `apiCallFailure`, and the loader gets a 503 `Response`
1934
+ with no body (the reason is in the log).
1935
+
1936
+ **Why:** the API, or a gateway in front of it, answered a status that is not
1937
+ 401, 403 or 404 with a body that is not GraphQL (an HTML 502 page, a 429
1938
+ from a rate limiter). The log line's second argument is that body.
1939
+
1940
+ **Fix:** read the body in the log and fix the gateway. If a status such as 429
1941
+ should reach the page as its own, name it:
1942
+
1943
+ ```ts
1944
+ import { apiCallFailure } from '@softistx/alxia-react-router/errors';
1945
+
1946
+ export const failed = (error: unknown) =>
1947
+ apiCallFailure(error, {
1948
+ api: 'my-api',
1949
+ passedThrough: new Set([401, 403, 404, 429]),
1950
+ });
1951
+ ```
1952
+
1953
+ ### `<api>: <operation> (request <id>) unreachable`, `timeout` or `invalid-response`
1954
+
1955
+ Logged as an error by `apiCallFailure`, and the loader gets a 503 `Response`
1956
+ with no body (the reason is in the log line).
1957
+
1958
+ **Why:** `@nxgt/graphql-client` could not get an answer: `unreachable` is a
1959
+ refused connection or a DNS failure, `timeout` is a call past the deadline the
1960
+ app gave it, and `invalid-response` is an answer that is no GraphQL response
1961
+ (a 2xx with no `data`, garbled JSON). The log line's second argument is the
1962
+ cause.
1963
+
1964
+ **Fix:** check the API's address and that it is up. For a `timeout`, the call's
1965
+ `timeout` option is the app's, not the package's. The 503 reaches the error
1966
+ page through `routeError`, which words it with the request id when there is
1967
+ one.
1968
+
1969
+ ### `<api>: <operation> (request <id>) aborted`
1970
+
1971
+ Logged as an error by `apiCallFailure`, and the loader gets a 503 `Response`.
1972
+
1973
+ **Why:** the `signal` you passed was aborted, so the visitor closed the tab or
1974
+ navigated away, and the call failed with whatever error that produced. Nobody
1975
+ sees the 503.
1976
+
1977
+ **Fix:** none. To keep it out of the logs, test `request.signal.aborted` in
1978
+ your own `catch` before calling `apiCallFailure`.
1979
+
1980
+ ### `TypeError: sessionCookies(): the … name "…" is not a cookie name (an RFC 6265 token: …). Pass a name such as "my-app_session".`
1981
+
1982
+ ```
1983
+ TypeError: sessionCookies(): the session name "Bad Name" is not a cookie name (an RFC 6265 token: letters, digits and ! # $ % & ' * + - . ^ _ ` | ~). Pass a name such as "my-app_session".
1984
+ ```
1985
+
1986
+ **When:** the server starts, or the module that calls `sessionCookies` is imported.
1987
+
1988
+ **Why:** `session` or `challenge` is empty or holds a character a cookie name cannot, such as a space, a semicolon, a comma or `=`. The message says which of the two (`session` or `challenge`) it is. A name from an environment variable that was not set is the usual cause.
1989
+
1990
+ **Fix:** pass a plain name, such as the app's name and the role:
1991
+
1992
+ ```ts
1993
+ import { sessionCookies } from '@softistx/alxia-react-router/session';
1994
+
1995
+ export const cookies = sessionCookies({
1996
+ session: 'my-app_session',
1997
+ challenge: 'my-app_challenge',
1998
+ secure: !import.meta.env.DEV,
1999
+ });
2000
+ ```
2001
+
2002
+ ### `TypeError: sessionCookies(): the … name "…" already carries a prefix. Pass the base name: the package adds __Host- (session) or __Secure- (challenge) when secure is true.`
2003
+
2004
+ ```
2005
+ TypeError: sessionCookies(): the session name "__Host-my-app_session" already carries a prefix. Pass the base name: the package adds __Host- (session) or __Secure- (challenge) when secure is true.
2006
+ ```
2007
+
2008
+ **When:** the server starts, or the module that calls `sessionCookies` is imported.
2009
+
2010
+ **Why:** the name starts with `__Host-` or `__Secure-`. The package adds the prefix itself when `secure` is `true` and drops it when `secure` is `false` (development over plain HTTP, where a prefixed cookie would be refused); a name that carries it would be doubled or stuck in development.
2011
+
2012
+ **Fix:** pass the base name: `'my-app_session'`, not `'__Host-my-app_session'`. The name the browser sees is in `cookies.names`. If the app reads or clears the cookie elsewhere by its full name, read it from `cookies.names.session`.
2013
+
2014
+ ### `TypeError: sessionCookies(): challengeHostPrefix needs challengePath: "/" (a __Host- cookie must have Path=/); got ….`
2015
+
2016
+ ```
2017
+ TypeError: sessionCookies(): challengeHostPrefix needs challengePath: "/" (a __Host- cookie must have Path=/); got "/sign-in".
2018
+ ```
2019
+
2020
+ **When:** the server starts, or the module that calls `sessionCookies` is imported.
2021
+
2022
+ **Why:** `challengeHostPrefix: true` names the challenge `__Host-<name>`, and browsers refuse a `__Host-` cookie that is not `Path=/`. The default `challengePath` is `/sign-in`.
2023
+
2024
+ **Fix:** pass `challengePath: '/'` with it: `sessionCookies({ session, challenge, challengePath: '/', challengeHostPrefix: true, secure })`.
2025
+
2026
+ ### `TypeError: sessionCookies(): challengeSeconds must be a positive integer; got ….`
2027
+
2028
+ ```
2029
+ TypeError: sessionCookies(): challengeSeconds must be a positive integer; got 0.
2030
+ ```
2031
+
2032
+ **When:** the server starts, or the module that calls `sessionCookies` is imported.
2033
+
2034
+ **Why:** `challengeSeconds`, the most the second-factor challenge's cookie lives, is `0`, negative, fractional or `NaN` (a lifetime read from an environment variable that is empty gives `NaN`). With `0` the browser would drop the cookie at once and the code page would never find its challenge.
2035
+
2036
+ **Fix:** pass whole seconds above 0, or leave it out for the default of 300, the lifetime of an `@softistx/janus` challenge. A longer value gains nothing: the cookie also ends with the challenge itself.
2037
+
2038
+ ### `TypeError: sessionCookies(): challengePath must start with "/" and hold no ";" or control character; got ….`
2039
+
2040
+ ```
2041
+ TypeError: sessionCookies(): challengePath must start with "/" and hold no ";" or control character; got "sign-in".
2042
+ ```
2043
+
2044
+ **When:** the server starts, or the module that calls `sessionCookies` is imported.
2045
+
2046
+ **Why:** `challengePath`, where the browser sends the challenge cookie, is a relative path such as `'sign-in'` (a cookie's `Path` must be absolute, or the browser ignores it), or it holds a `;` or a control character, which would open another attribute of the `Set-Cookie` header.
2047
+
2048
+ **Fix:** pass the path of the sign-in pages with its leading slash. The default is `'/sign-in'`, which covers `/sign-in` and the pages under it; not `/sign-in/code` alone, since a client navigation fetches `/sign-in/code.data`, which that path would not match.
2049
+
2050
+ ### `TypeError: sessionCookies(): sameSite must be "lax", "strict" or "none"; got ….`
2051
+
2052
+ ```
2053
+ TypeError: sessionCookies(): sameSite must be "lax", "strict" or "none"; got "sometimes".
2054
+ ```
2055
+
2056
+ **When:** the module that calls `sessionCookies`, `signedSession` or `serializeCookie` is imported (the message starts with that function's name).
2057
+
2058
+ **Why:** `sameSite` is one of the three values, in lower case.
2059
+
2060
+ **Fix:** pass `'lax'` (the default), `'strict'` or `'none'`.
2061
+
2062
+ ### `TypeError: sessionCookies(): sameSite "none" needs secure: true, since a browser drops a SameSite=None cookie without Secure.`
2063
+
2064
+ **When:** `sameSite: 'none'` with `secure: false` (development over plain HTTP).
2065
+
2066
+ **Why:** a browser drops a `SameSite=None` cookie that is not `Secure`.
2067
+
2068
+ **Fix:** use `'lax'` or `'strict'` in development, for example `sameSite: import.meta.env.DEV ? 'lax' : 'none'`.
2069
+
2070
+ ### `TypeError: signedSession(): secret must be a string of at least 32 characters.`
2071
+
2072
+ **When:** the module that calls `signedSession` is imported, often because the secret's environment variable is unset and `?? ''` gave an empty string.
2073
+
2074
+ **Why:** an HMAC key shorter than 32 characters is guessable.
2075
+
2076
+ **Fix:** set the variable to a random value of 32 characters or more (`openssl rand -base64 32`). Changing it later signs every operator out.
2077
+
2078
+ ### `TypeError: signedSession(): the name "…" must be an RFC 6265 token without a __Host- or __Secure- prefix; …` or `maxAge must be a positive integer of seconds; got ….`
2079
+
2080
+ **When:** the module that calls `signedSession` is imported.
2081
+
2082
+ **Why:** the name is not a cookie name or already carries a prefix (the package adds `__Host-` when `secure`), or `maxAge` is not a positive whole number of seconds.
2083
+
2084
+ **Fix:** pass a base name such as `'my-app_operator'` and `maxAge: 8 * 60 * 60`.
2085
+
2086
+ ### `TypeError: createSignInThrottle(): … must be a positive integer; got ….` or `… must be a positive integer or 0; got ….`
2087
+
2088
+ **When:** the module that calls `createSignInThrottle` is imported (the message names the option: `max`, `windowMs`, `maxKeys`, `globalMax`, `globalWindowMs`, `maxDelayMs`, `maxConcurrentVerifies` or `maxQueuedVerifies`).
2089
+
2090
+ **Why:** the option is not a whole number above 0 (`maxQueuedVerifies` may be 0, and then the message ends `or 0`), often a value read from the environment as a string or `NaN`.
2091
+
2092
+ **Fix:** convert it first, `max: Number(process.env.SIGNIN_MAX ?? 5)`.
2093
+
2094
+ ### `TypeError: createSignInThrottle(): globalMode must be 'refuse' or 'delay'; got ….`
2095
+
2096
+ **When:** the module that calls `createSignInThrottle` is imported.
2097
+
2098
+ **Why:** `globalMode` is neither `'refuse'` (the default) nor `'delay'`, often a value read from the environment or a typo.
2099
+
2100
+ **Fix:** pass one of the two: `globalMode: 'delay'`. See [the delay-only global bucket](guide/session.md#a-delay-only-global-bucket).
2101
+
2102
+ ### `TypeError: signInFlow(): paths.… must be a path of this site with no query or fragment, starting with a single "/"; got ….`
2103
+
2104
+ ```
2105
+ TypeError: signInFlow(): paths.secondFactor must be a path of this site with no query or fragment, starting with a single "/"; got "sign-in/code".
2106
+ ```
2107
+
2108
+ **When:** the server starts, or the module that calls `signInFlow` is imported.
2109
+
2110
+ **Why:** `paths.signIn` or `paths.secondFactor` (the message names which) is relative, empty, starts with `//` or `/\`, which a redirect reads as another site, or holds a query (`?`) or a fragment (`#`), which the flow appends to (`?next=`, `?signed-out=1`). The flow redirects to these paths.
2111
+
2112
+ **Fix:** pass the page's path with its leading slash, or leave `paths` out for `/sign-in` and `/sign-in/second-factor`:
2113
+
2114
+ ```ts
2115
+ import { signInFlow } from '@softistx/alxia-react-router/session';
2116
+
2117
+ export const signIn = signInFlow({
2118
+ // …
2119
+ paths: { secondFactor: '/sign-in/code' },
2120
+ });
2121
+ ```
2122
+
2123
+ ### `TypeError: signInPath(): options.path must be a path of this site with no query or fragment, starting with a single "/"; got ….`
2124
+
2125
+ ```
2126
+ TypeError: signInPath(): options.path must be a path of this site with no query or fragment, starting with a single "/"; got "//evil.test".
2127
+ ```
2128
+
2129
+ **When:** the app calls `signInPath(next, { path })`, in a loader or at startup.
2130
+
2131
+ **Why:** `path` replaces `/sign-in` and the function adds `?next=…` to it, so it must be a path of this site: relative, empty, starting with `//` or `/\` (which a redirect reads as another site), or holding a query (`?`) or a fragment (`#`) is refused. The message prints the path only up to its `?` or `#`.
2132
+
2133
+ **Fix:** pass the page's path with its leading slash, and put parameters in `query`:
2134
+
2135
+ ```ts
2136
+ import { signInPath } from '@softistx/alxia-react-router/session/model';
2137
+
2138
+ signInPath('/orders', { path: '/login', query: { expired: '1' } });
2139
+ ```
2140
+
2141
+ ### `TypeError: signInFlow(): json must come from jsonActions(), which carries the site check every step runs; this object has none (a hand-made double?). Pass the app's jsonActions({ origin }) instance, or a spread copy of it.`
2142
+
2143
+ ```
2144
+ TypeError: signInFlow(): json must come from jsonActions(), which carries the site check every step runs; this object has none (a hand-made double?). Pass the app's jsonActions({ origin }) instance, or a spread copy of it.
2145
+ ```
2146
+
2147
+ **When:** the server starts, or the module that calls `signInFlow` is imported.
2148
+
2149
+ **Why:** every step of the flow runs the same guard first (a native form post goes back to its page, a JSON post from another site is a 403). The guard's rule lives on the instance `jsonActions()` returns, under a registered symbol. A hand-made object with `readJson`, `requireJsonPost` and `readInput` has none, so the steps could not refuse another site.
2150
+
2151
+ **Fix:** pass the app's `jsonActions({ origin })` instance, or a spread copy of it, which keeps the rule:
2152
+
2153
+ ```ts
2154
+ import { jsonActions } from '@softistx/alxia-react-router/errors';
2155
+
2156
+ export const json = jsonActions({ origin: () => process.env.APP_ORIGIN });
2157
+ ```
2158
+
2159
+ ### `TypeError: signInFlow(): the code "…" is both the wrong-code code (codes.invalidCode) and in codes.challengeOver. A wrong code that leaves tries cannot end the challenge.`
2160
+
2161
+ ```
2162
+ TypeError: signInFlow(): the code "auth.errors.invalid-code" is both the wrong-code code (codes.invalidCode) and in codes.challengeOver. A wrong code that leaves tries cannot end the challenge.
2163
+ ```
2164
+
2165
+ **When:** the server starts, or the module that calls `signInFlow` is imported.
2166
+
2167
+ **Why:** `codes.invalidCode`, the refusal of a wrong code, also appears in `codes.challengeOver`, the codes that end the challenge. The flow could not tell whether a refused code leaves tries or sends the user back to the password.
2168
+
2169
+ **Fix:** list in `challengeOver` the codes of a challenge that is gone (unknown, spent, expired) and keep the wrong-code code out of it:
2170
+
2171
+ ```ts
2172
+ signInFlow({
2173
+ // …
2174
+ codes: {
2175
+ invalidCode: 'auth.errors.invalid-code',
2176
+ challengeOver: ['auth.errors.invalid-token'],
2177
+ },
2178
+ });
2179
+ ```
2180
+
2181
+ ### `TypeError: serializeCookie(): the name "…" is not a cookie name (an RFC 6265 token).`
2182
+
2183
+ ```
2184
+ TypeError: serializeCookie(): the name "a b" is not a cookie name (an RFC 6265 token).
2185
+ ```
2186
+
2187
+ **When:** the app calls `serializeCookie` for a cookie of its own (a language, a preference).
2188
+
2189
+ **Why:** the name is empty or holds a space, `;`, `=`, a control character or another character a cookie name cannot. Written as it is, it would break the `Set-Cookie` header or open another attribute, so the package refuses it. `sessionCookies` checks its names the same way, with its own messages.
2190
+
2191
+ **Fix:** use a plain name, letters, digits and `- _ .`:
2192
+
2193
+ ```ts
2194
+ import { serializeCookie } from '@softistx/alxia-react-router/session';
2195
+
2196
+ const header = serializeCookie('my-app_language', 'fr', {
2197
+ maxAge: 60 * 60 * 24 * 365,
2198
+ secure: !import.meta.env.DEV,
2199
+ });
2200
+ ```
2201
+
2202
+ ### `TypeError: serializeCookie(): the path "…" is not a cookie path: it must start with "/" and hold no ";" or control character.`
2203
+
2204
+ ```
2205
+ TypeError: serializeCookie(): the path "sign-in" is not a cookie path: it must start with "/" and hold no ";" or control character.
2206
+ ```
2207
+
2208
+ **When:** the app calls `serializeCookie` with a `path`, or `sessionCookies` builds its challenge cookie (that one reports a `challengePath` error instead).
2209
+
2210
+ **Why:** the `path` is relative, or it holds a `;` or a control character such as a line break, which would end the attribute and let the rest of the string set another one. A path built from a request's URL is the usual source.
2211
+
2212
+ **Fix:** pass a path of your own with its leading slash, and never one taken from a request. Leave `path` out for the default, `/`.
2213
+
2214
+ ### `TypeError: stepUpSteps(): the code "…" is both the wrong-code code (codes.invalidCode) and in codes.challengeOver. A wrong code that leaves tries cannot end the challenge.`
2215
+
2216
+ ```
2217
+ TypeError: stepUpSteps(): the code "auth.errors.invalid-code" is both the wrong-code code (codes.invalidCode) and in codes.challengeOver. A wrong code that leaves tries cannot end the challenge.
2218
+ ```
2219
+
2220
+ **When:** the server starts, or the module that calls `stepUpSteps` is imported.
2221
+
2222
+ **Why:** `codes.invalidCode`, the refusal of a wrong code, also appears in `codes.challengeOver`, the codes that end the challenge. A wrong code leaves tries (`attemptsLeft`) and the step could not tell it from a challenge that is gone. Passing `challengeOver` replaces the default list, so a list copied from a sign-in's codes is the usual cause.
2223
+
2224
+ **Fix:** list in `challengeOver` the codes of a challenge that is gone and keep the wrong-code code out of it:
2225
+
2226
+ ```ts
2227
+ stepUpSteps({
2228
+ // …
2229
+ codes: {
2230
+ invalidCode: 'auth.errors.invalid-code',
2231
+ challengeOver: ['auth.errors.invalid-token', 'auth.errors.second-factor-state'],
2232
+ },
2233
+ });
2234
+ ```
2235
+
2236
+ ### `TypeError: stepUpSteps(): onSignedOut: 'sign-in' needs signIn.signInRedirect, which the sign-in given has not.`
2237
+
2238
+ ```
2239
+ TypeError: stepUpSteps(): onSignedOut: 'sign-in' needs signIn.signInRedirect, which the sign-in given has not.
2240
+ ```
2241
+
2242
+ **When:** the server starts, or the module that calls `stepUpSteps` is imported.
2243
+
2244
+ **Why:** `onSignedOut: 'sign-in'` redirects a signed-out user through the sign-in's `signInRedirect`, and the `signIn` given, a hand-written `StepUpSignIn`, does not have it. A `signInFlow(...)` always does.
2245
+
2246
+ **Fix:** add `signInRedirect` to the object, or leave `onSignedOut` out and handle the signed-out failure in the app:
2247
+
2248
+ ```ts
2249
+ stepUpSteps({
2250
+ signIn: { errors, json, attemptsLeft, signInRedirect: (request) => redirect('/sign-in') },
2251
+ spent: (language) => t('step-up.spent', {}, language),
2252
+ onSignedOut: 'sign-in',
2253
+ });
2254
+ ```
2255
+
2256
+ ### `docs/flows/…: <what is wrong with the front-matter>`
2257
+
2258
+ A `FlowFormatError`, thrown by `loadHelpFlows` (at module load) and reported as
2259
+ a `bad-flow` problem by `help check`. The message starts with the file and, for
2260
+ a syntax error, the line (`docs/flows/editor.fr.md:4: …`). The text after it is
2261
+ one of:
2262
+
2263
+ - `the file name must be <role>.<lang>.md, e.g. editor.fr.md`: rename the file.
2264
+ - `the file must start with a "---" front-matter block`, `the front-matter is not closed by a "---" line`.
2265
+ - `front-matter "id" is required: …`, `"title" is required`, `"roles" is missing`, `"roles" lists at least one role`, `"routes" lists the route ids the flow covers (or set overview: true)`: add the key.
2266
+ - `unknown front-matter key "x" (known: …)`: a typo, or a key the format does not have.
2267
+ - `front-matter "roles" must be a list of non-empty strings, e.g. roles: [a, b]`.
2268
+ - `capture step 5 is not a step of this flow (it has 3)`, `capture "x" needs an "alt" text`, `step 2 has two captures; a step has one`.
2269
+ - `flow id "x" is already used by …`: ids are unique per language.
2270
+ - `indent with spaces, not tabs`, `duplicate key "x"`, `expected "key: value", got: …`, `unclosed list: …`: YAML syntax; quote a value that contains ` #`.
2271
+
2272
+ See [the front-matter](guide/help.md#front-matter).
2273
+
2274
+ ### `capture file x.1440.light.webp is missing from docs/flows/captures/`
2275
+
2276
+ A step cites a capture and one of its four variants is not there. Add
2277
+ `<name>.<1440|360>.<light|dark>.webp` to `docs/flows/captures/`. `help check`
2278
+ words it `…: capture x.360.dark.webp is missing from docs/flows/captures/`.
2279
+
2280
+ ### `route "x" is covered by no flow: cite it in a flow's routes, or add it to the ignore list`
2281
+
2282
+ `help check`: a screen route (no children) is cited by no flow, and no layout
2283
+ above it is either. Write the flow and list the route id (or a layout above it,
2284
+ which covers every screen under it) in its `routes`, or pass the id to `--ignore` when it is
2285
+ a resource route or a redirect (`*` matches any run of characters).
2286
+
2287
+ ### `…: cites route "x", which is not in the route config`
2288
+
2289
+ `help check`: a flow cites a route id `routes.ts` no longer has. Ids are the
2290
+ route's file without its extension, or its `id`; fix the flow or restore the route.
2291
+
2292
+ ### `ignore "x" matches no route`
2293
+
2294
+ `help check`: an `--ignore` entry matches nothing. Remove it.
2295
+
2296
+ ### `…: the default export must be the route config (an array)`
2297
+
2298
+ `help check` imports `app/routes.ts` and awaits its default export. Export the
2299
+ array (`--routes <file>` for another path). A `routes.ts` that calls
2300
+ `flatRoutes()` needs Vite's plugin context and cannot be imported this way: pass
2301
+ the routes to `checkHelp({ config })` instead.
2302
+
2303
+ ### `The returned state is not the one this sign-in sent.` and the other `OidcError` messages (`/oidc`)
2304
+
2305
+ **When:** `oidc.callback(request)` throws an `OidcError` and nothing catches it:
2306
+ the log prints `OidcError: <message>` (for example "The sign-in challenge
2307
+ cookie is missing or unreadable …", "The id token nonce is not the one this
2308
+ sign-in sent.", "The id token was refused: …"). `error.code` says which step
2309
+ refused.
2310
+
2311
+ **Why, by code:**
2312
+
2313
+ - `missing-challenge` / `challenge-expired`: the `__Host-<name>_flow` cookie did
2314
+ not come back: the sign-in was started on another host or browser, more than
2315
+ ten minutes ago, `SESSION_SECRET` changed in between, or `secure: true` runs
2316
+ over `http://` (the browser drops a `Secure` cookie).
2317
+ - `state-mismatch`: a second sign-in tab overwrote the cookie, or the callback
2318
+ was forged.
2319
+ - `nonce-mismatch`: the issuer returned an id token for another sign-in.
2320
+ - `invalid-id-token`: the message names `jose`'s reason. `aud` is not your
2321
+ `clientId`; `iss` differs from `issuer` (a trailing slash or `http` against
2322
+ `https` counts); `exp` or `iat` is outside `clockToleranceSeconds` (a skewed
2323
+ clock); or the algorithm is not in `algorithms`.
2324
+ - `provider-error`: the issuer sent the user back with `?error=` (access
2325
+ denied, login required); the message holds its `error` and description.
2326
+ - `missing-code`: the callback carries neither a code nor an error.
2327
+ - `refresh-failed`: the token endpoint refused the refresh token; `oidcUser`
2328
+ treats it as signed out once the access token has ended.
2329
+ - `discovery-failed` / `issuer-mismatch`: the issuer's
2330
+ `/.well-known/openid-configuration` is unreachable, or names another
2331
+ `issuer` than the one configured (`issuer-mismatch` also when the callback's
2332
+ `iss` parameter names another issuer).
2333
+ With `revokeOnLogout`, discovery can also fail at `logout`: it goes to
2334
+ `onRevokeError`, never thrown, and the user is signed out locally.
2335
+ - `revoke-failed`: reported to `onRevokeError` only, never thrown: `logout`
2336
+ with `revokeOnLogout: true` could not reach the issuer's
2337
+ `revocation_endpoint`, got a non-2xx answer (`invalid_client`: the secret or
2338
+ authentication method; a 5xx: the issuer), or did not answer within
2339
+ `revokeTimeoutMs` (3000 ms by default, both calls together). The user is
2340
+ signed out locally all the same, but the refresh token may still be valid at
2341
+ the issuer until it expires: retry on the issuer's side, or check its
2342
+ revocation settings. Nothing is revoked, and nothing is reported, when
2343
+ discovery has no `revocation_endpoint`.
2344
+ - `par-failed`: `signIn` could not push the authorization request. The message
2345
+ holds the issuer's `error` (`invalid_client`: the secret or authentication
2346
+ method; `invalid_request`: a parameter the issuer refuses, often a
2347
+ `redirectUri` not registered), or says the issuer publishes no
2348
+ `pushed_authorization_request_endpoint` (set `par: 'never'`, or fix discovery).
2349
+ An issuer that answers `invalid_request` (pushed authorization request
2350
+ required) to a plain redirect needs `par: 'auto'` (the default) or
2351
+ `'always'`.
2352
+ - `token-exchange-failed` with `use_dpop_nonce` or `invalid_dpop_proof` in the
2353
+ message: with `dpop` on, the issuer refused the proof. `use_dpop_nonce` twice
2354
+ in a row means the server rotated its nonce between the two calls; try again.
2355
+ `invalid_dpop_proof` usually means a skewed clock (`iat`) or an `alg` the
2356
+ issuer does not accept (see `dpop_signing_alg_values_supported`: use
2357
+ `dpop: { alg: 'EdDSA' }` or `'ES256'`). `invalid_dpop_proof` with `dpop` off
2358
+ means the issuer requires DPoP: turn it on.
2359
+ - `token-exchange-failed` with "did not issue a bearer token": the issuer
2360
+ answered `token_type: DPoP` and `dpop` is not set.
2361
+ - `token-exchange-failed`: the message holds the issuer's `error`, usually
2362
+ `invalid_client` (wrong secret, or a public client that sent one) or
2363
+ `invalid_grant` (a `redirectUri` that differs from the registered one, or a
2364
+ code used twice).
2365
+
2366
+ **Fix:** answer it in the route, clearing the spent challenge with the error's
2367
+ headers, and let the user start again:
2368
+
2369
+ ```ts
2370
+ catch (error) {
2371
+ if (error instanceof OidcError) {
2372
+ throw redirect('/sign-in?error=' + error.code, { headers: error.headers });
2373
+ }
2374
+ throw error;
2375
+ }
2376
+ ```
2377
+
2378
+ See the [OIDC guide](guide/oidc.md).
2379
+
2380
+ ## Types
2381
+
2382
+ ### `Property 'alxia' does not exist on type 'Readonly<RouterContextProvider>'`
2383
+
2384
+ ```text
2385
+ app/routes/home.tsx: error TS2339: Property 'alxia' does not exist on type 'Readonly<RouterContextProvider>'.
2386
+ ```
2387
+
2388
+ **When:** a loader or an action typed with the generated `Route.LoaderArgs`
2389
+ or `Route.ActionArgs` reads `context.alxia`. At runtime it is there; only
2390
+ `tsc` refuses it.
2391
+
2392
+ **Why:** this package augments `RouterContextProvider` as `react-router`
2393
+ exports it, whose types are `dist/production`'s. The generated `+types`
2394
+ files read their argument types from `react-router/internal`, whose types,
2395
+ in react-router 8.4 and 8.5, point at `dist/development`: a second declaration of
2396
+ the class, which no exported path reaches, so no augmentation can add
2397
+ `alxia` to it.
2398
+
2399
+ **Fix:** wrap the loader in `withAlxia`, which hands it `alxia` typed the
2400
+ same way, and keeps the generated `loaderData`:
2401
+
2402
+ ```ts
2403
+ import { type AlxiaArgs, withAlxia } from '@softistx/alxia-react-router';
2404
+ import type { Route } from './+types/home';
2405
+
2406
+ export const loader = withAlxia(({ alxia }: Route.LoaderArgs & AlxiaArgs) => {
2407
+ return { name: alxia.user?.name ?? null };
2408
+ });
2409
+ ```
2410
+
2411
+ Or read `alxiaOf(context)` inside the plain function.
2412
+
2413
+ Or type the arguments with `LoaderFunctionArgs` from `react-router`, which
2414
+ sees `context.alxia`, at the cost of the generated `params`. Typing it under
2415
+ `Route.LoaderArgs` waits on react-router pointing both entries at the same
2416
+ declarations.
2417
+
2418
+ ### `Property '…' does not exist on type 'BaseContext & …'`
2419
+
2420
+ ```text
2421
+ error TS2339: Property 'tenant' does not exist on type 'BaseContext & Empty & { requestId: string; log: RequestLog; } & { user: { name: string; } | null; }'.
2422
+ ```
2423
+
2424
+ **When:** a loader reads, through `alxiaOf`, or `getLoadContext`
2425
+ destructures, something no middleware of the server derives. With the type
2426
+ `'BaseContext & Empty'` alone, `alxiaOf(context)` has no server to read:
2427
+ `app/server.ts` has no `Register` declaration, or there is no
2428
+ `app/server.ts`, and `@softistx/alxia`'s `Register` names no base either.
2429
+ With core's `Register` alone, `alxiaOf` reads that base: a key
2430
+ `configure` adds after it is missing.
2431
+
2432
+ **Why:** the type is the app's context at the point of the catch-all, as
2433
+ for any route: "order is meaning".
2434
+
2435
+ **Fix:** derive it in `configure`, and register the server once:
2436
+
2437
+ ```ts
2438
+ // app/server.ts
2439
+ import { createServer } from '@softistx/alxia-react-router';
2440
+
2441
+ const server = createServer({
2442
+ configure: (app) =>
2443
+ app.derive(({ request }) => ({ tenant: request.headers.get('x-tenant') ?? 'default' })),
2444
+ });
2445
+ export default server;
2446
+
2447
+ declare module '@softistx/alxia-react-router' {
2448
+ interface Register {
2449
+ server: typeof server;
2450
+ }
2451
+ }
2452
+ ```
2453
+
2454
+ ### `Type '…' does not satisfy the constraint 'AnyAlxia | ReactRouterServer<AnyAlxia>'`
2455
+
2456
+ ```text
2457
+ error TS2344: Type '{ user: string; }' does not satisfy the constraint 'AnyAlxia | ReactRouterServer<AnyAlxia>'.
2458
+ ```
2459
+
2460
+ **When:** `alxiaOf<T>()` is given a type that is neither a server nor an
2461
+ alxia app, such as the context's own shape.
2462
+
2463
+ **Why:** the type argument is what the context is read from, as
2464
+ `ContextOf<App>` reads an app.
2465
+
2466
+ **Fix:** pass the server's type, or register it and pass nothing:
2467
+
2468
+ ```ts
2469
+ // app/server.ts
2470
+ export type Server = typeof server;
2471
+
2472
+ // app/routes/home.tsx
2473
+ import type { Server } from '../server';
2474
+ const { user } = alxiaOf<Server>(context);
2475
+ ```
2476
+
2477
+ ### `Type '(app: …) => void' is not assignable to type '(app: …) => AnyAlxia'`
2478
+
2479
+ ```text
2480
+ error TS2322: Type '(app: FreshApp) => void' is not assignable to type '(app: FreshApp) => AnyAlxia'.
2481
+ Type 'void' is not assignable to type 'AnyAlxia'.
2482
+ ```
2483
+
2484
+ **When:** `configure` or `beforeAll` has a body that declares on `app` and
2485
+ returns nothing.
2486
+
2487
+ **Why:** each returns the app it built: that return is how its types reach
2488
+ the loaders and `getLoadContext`.
2489
+
2490
+ **Fix:** return the chain:
2491
+
2492
+ ```ts
2493
+ createServer({
2494
+ configure: (app) => app.get('/api/health', ({ reply }) => reply.ok({ ok: true })),
2495
+ });
2496
+ ```
2497
+
2498
+ ### `Property '…' does not exist on type 'BaseContext & { readonly 'Register.server must be typeof server, the default export of createServer()': never; }'`
2499
+
2500
+ ```text
2501
+ error TS2339: Property 'user' does not exist on type 'BaseContext & { readonly 'Register.server must be typeof server, the default export of createServer()': never; }'.
2502
+ ```
2503
+
2504
+ **When:** every `alxiaOf(context)` read fails with it: `Register`'s
2505
+ `server` names something that is neither a server nor an alxia app, most
2506
+ often the module rather than its default export,
2507
+ `server: typeof import('./server')`.
2508
+
2509
+ **Why:** a wrong registration types the context as one marker key, so
2510
+ that each read is a compile error rather than `never`, which would let
2511
+ anything through.
2512
+
2513
+ **Fix:** name the default export's type:
2514
+
2515
+ ```ts
2516
+ // app/server.ts
2517
+ const server = createServer({ configure: (app) => app });
2518
+ export default server;
2519
+
2520
+ declare module '@softistx/alxia-react-router' {
2521
+ interface Register {
2522
+ server: typeof server;
2523
+ }
2524
+ }
2525
+ ```
2526
+
2527
+ ### `Subsequent property declarations must have the same type. Property 'server' must be of type …`
2528
+
2529
+ ```text
2530
+ error TS2717: Subsequent property declarations must have the same type. Property 'server' must be of type 'ReactRouterServer<…>', but here has type 'ReactRouterServer<…>'.
2531
+ ```
2532
+
2533
+ **When:** two files of one TypeScript program declare `Register`'s
2534
+ `server`: two React Router apps under one tsconfig, or a copy of the
2535
+ declaration left in a second file.
2536
+
2537
+ **Why:** a program has one `Register`, and it names one server: the one
2538
+ whose catch-all every loader of the build runs behind.
2539
+
2540
+ **Fix:** keep one declaration per app, beside its server. Give each app of
2541
+ a monorepo its own tsconfig, or drop `Register` and pass the type
2542
+ argument, `alxiaOf<Server>(context)`.
2543
+
2544
+ ### `Type '{ …; nonce: string | undefined; }' is not assignable to type 'ServerRouterProps' with 'exactOptionalPropertyTypes: true'`
2545
+
2546
+ **When:** `entry.server.tsx` passes `nonceOf(loadContext)` to
2547
+ `<ServerRouter nonce>` under `exactOptionalPropertyTypes`.
2548
+
2549
+ ```text
2550
+ error TS2375: Type '{ context: EntryContext; url: string; nonce: string | undefined; }' is not assignable to type 'ServerRouterProps' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
2551
+ ```
2552
+
2553
+ **Why:** `nonceOf` returns `undefined` when no middleware set a nonce, and
2554
+ `ServerRouterProps.nonce` is optional without `undefined`. React's
2555
+ `nonce` option takes `undefined`, so only the prop complains.
2556
+
2557
+ **Fix:** use `@softistx/alxia-react-router/entry`, whose `handleRequest` does it
2558
+ ([guide](guide/document.md#the-entry)), or spread the prop in only when
2559
+ there is a nonce, in an entry of your own:
2560
+
2561
+ ```tsx
2562
+ const nonce = nonceOf(loadContext);
2563
+ <ServerRouter
2564
+ context={routerContext}
2565
+ url={request.url}
2566
+ {...(nonce === undefined ? {} : { nonce })}
2567
+ />
2568
+ ```
2569
+
2570
+ ## Traps
2571
+
2572
+ ### `bun build/server/index.js` exits at once, printing nothing
2573
+
2574
+ **Why:** the build was made without the plugin, so `build/server/index.js`
2575
+ is React Router's plain server build: a module of exports, which listens
2576
+ on nothing. Or it was imported, not run: the server listens only when it
2577
+ is the process's entry point.
2578
+
2579
+ **Fix:** add `alxia()` to `vite.config.ts` and build again; the start line
2580
+ `alxia listening on <url>` then comes up. Run the file itself,
2581
+ `bun build/server/index.js`, not through another module's `import`.
2582
+
2583
+ ### A script of the page has no nonce
2584
+
2585
+ The policy names `'nonce-…'`, and the browser refuses some or all of the
2586
+ page's scripts: `Refused to execute inline script because it violates the
2587
+ following Content Security Policy directive: "script-src 'self'
2588
+ 'nonce-…'"`. The page renders, then never hydrates.
2589
+
2590
+ **Why:** one of these:
2591
+
2592
+ - the app has no `entry.server.tsx`, so React Router's default renders
2593
+ with no nonce;
2594
+ - the entry does not pass it to both `<ServerRouter nonce>` and the
2595
+ renderer's `nonce` option: the first covers React Router's scripts, the
2596
+ second React's own streaming ones;
2597
+ - a `<script>` of the app's own, in `root.tsx` say, has no `nonce`
2598
+ attribute.
2599
+
2600
+ **Fix:** reveal the entry and pass `nonceOf(loadContext)` to both
2601
+ ([guide](guide/csp-nonce.md#a-csp-nonce)). A script of your own reads the nonce
2602
+ through a loader, where `nonceOf(context)` works as well:
2603
+
2604
+ ```tsx
2605
+ // app/root.tsx
2606
+ import { nonceOf } from '@softistx/alxia-react-router';
2607
+ import type { Route } from './+types/root';
2608
+
2609
+ export function loader({ context }: Route.LoaderArgs) {
2610
+ return { nonce: nonceOf(context) };
2611
+ }
2612
+
2613
+ // in Layout: <script nonce={useRouteLoaderData('root')?.nonce}>…</script>
2614
+ ```
2615
+
2616
+ Check what was sent with
2617
+ `curl -s -A 'Mozilla/5.0 Chrome/130' http://localhost:5173/ | grep -o '<script[^>]*>'`:
2618
+ every tag should hold `nonce="…"`, the value of the response's
2619
+ `Content-Security-Policy`.
2620
+
2621
+ ### A loader reads `null` from the app's own key
2622
+
2623
+ The same cause as [`Error: No value found for context`](#error-no-value-found-for-context),
2624
+ with a key that has a default: `createContext<User | null>(null)`. The
2625
+ loader silently reads the default. Serve the app with the plugin, or read
2626
+ the context through `alxiaOf`.
2627
+
2628
+ ### A page answers alxia's JSON 404 or 405 instead of rendering
2629
+
2630
+ `{"error":"not_found"}` or `{"error":"method_not_allowed"}` where a page
2631
+ was expected.
2632
+
2633
+ **Why:** an alxia route's path covers the page's, and the core ranks it
2634
+ first wherever it was declared: segment by segment, a literal beats a
2635
+ parameter, which beats the catch-all's `/*`. Then the path is chosen
2636
+ before the method. So:
2637
+
2638
+ - `GET /:slug` takes `/about`, and every other one-segment page;
2639
+ - `POST /account` alone makes `GET /account` a 405, not the page;
2640
+ - a folder of `public/`, `public/blog/`, becomes `static('/blog', …)`, and
2641
+ `/blog/first-post` is its 404.
2642
+
2643
+ **Fix:** keep alxia's routes under a prefix the pages do not use, and
2644
+ `public/`'s folders apart from the page paths:
2645
+
2646
+ ```ts
2647
+ createServer({
2648
+ configure: (app) =>
2649
+ app.get('/api/posts/:slug', ({ params, reply }) => reply.ok({ slug: params.slug })),
2650
+ });
2651
+ ```
2652
+
2653
+ ### A streamed page arrives in one piece
2654
+
2655
+ The shell and its `<Suspense>` fallback should come first, and the
2656
+ deferred value later. If the whole page comes at once:
2657
+
2658
+ - **The client is a bot to `isbot`.** React Router's entry waits for
2659
+ `allReady` before it answers a bot, and `isbot('Bun/1.4.2')` is `true`:
2660
+ Bun's `fetch`, `curl` and most test clients get the finished page. Send a
2661
+ browser's user agent:
2662
+
2663
+ ```ts
2664
+ const BROWSER = 'Mozilla/5.0 (Macintosh) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0 Safari/537.36';
2665
+ await fetch(url, { headers: { 'user-agent': BROWSER } });
2666
+ ```
2667
+
2668
+ - **A compressor holds the stream.** One that does not flush after each
2669
+ chunk sends the page when it ends. `@softistx/alxia-compress` flushes a body with
2670
+ no `Content-Length` as it comes, so the cause is elsewhere: a proxy or a
2671
+ CDN in front of the server that buffers to compress. Compare with
2672
+ `accept-encoding: identity`, then without the proxy.
2673
+
2674
+ ### The logger times a streamed page at a few milliseconds
2675
+
2676
+ `@softistx/alxia-logger` writes its entry when the response's headers leave, so a
2677
+ page that streams for 800 ms is logged at its first byte. The duration is
2678
+ the server's time to first byte, not the page's.
2679
+
2680
+ ### A page, or a missing path, answers 401 behind a guard
2681
+
2682
+ A guard given to `use` in `configure` or `beforeAll` runs on every request
2683
+ it is in front of, a request no route matches included, and answers before
2684
+ the 404. An anonymous request to `/nope` gets the 401, not the 404, and so
2685
+ does the login page the guard sits in front of. Scope the guard to what it
2686
+ guards, with a path. A path-scoped `use` takes a middleware that adds nothing
2687
+ to the context, so `bearer`, which adds `user`, does not compile there: write
2688
+ the guard as a middleware that only refuses. The pages are a catch-all outside
2689
+ any `group`, so a `group` would not reach them.
2690
+
2691
+ ```ts
2692
+ import { defineMiddleware } from '@softistx/alxia';
2693
+
2694
+ const account = defineMiddleware(async ({ request, reply }, next) => {
2695
+ const token = request.headers.get('authorization')?.slice('Bearer '.length) ?? '';
2696
+ return (await jwt.verify(token)).ok ? next() : reply(401, { error: 'unauthorized' as const });
2697
+ });
2698
+
2699
+ createServer({
2700
+ configure: (app) => app.use('/account', account), // the pages under /account only
2701
+ });
2702
+ ```
2703
+
2704
+ ### The logger, CORS or secure headers miss the client's files
2705
+
2706
+ **When:** `pageHeaders` or `secureHeaders` is in `configure`, and a file under
2707
+ `build/client` (`/assets/*`, `public/`) answers with no `x-content-type-options`,
2708
+ `cross-origin-resource-policy` or `strict-transport-security`; the pages have
2709
+ them.
2710
+
2711
+ **Why:** a middleware in `configure` runs for the routes declared after it.
2712
+ The client's files are declared before `configure`, after `beforeAll`.
2713
+
2714
+ **Fix:** keep `pageHeaders` in `configure` for the pages, and add
2715
+ `secureHeaders` in `beforeAll` for the files, without a policy and without
2716
+ cache headers, so their `Cache-Control` stays as served
2717
+ ([the recipe](guide/csp-nonce.md#1-the-headers-in-appserverts)):
2718
+
2719
+ ```ts
2720
+ createServer({
2721
+ beforeAll: (app) =>
2722
+ app.use(logger()).use(secureHeaders({ contentSecurityPolicy: false })),
2723
+ configure: (app) => app.use(pageHeaders({ https: true })),
2724
+ });
2725
+ ```
2726
+
2727
+ Do not set `cacheControl` on the `beforeAll` one: `no-store` would reach
2728
+ `/assets` and end their caching.
2729
+
2730
+ ### A `page()` is not served under `react-router dev`
2731
+
2732
+ The app declares a `page()`, or reads `ctx.server.url`, `requestIP` or
2733
+ `timeout`, or `ctx.ip`, under `react-router dev` or `vite preview`; the same
2734
+ code works from `bun build/server/index.js`.
2735
+
2736
+ **Why:** under `@softistx/alxia-react-router/vite`, Vite owns the dev server, and
2737
+ the preview server under `vite preview`: a `node:http` server, not a
2738
+ `Bun.Server`. An HTTP request reaches the app through
2739
+ `app.fetch(request, side)`, where `side` is the loopback `Bun.serve` the
2740
+ plugin relays the app's sockets to. So `ctx.server` is that side server: its
2741
+ `publish` reaches the app's sockets, but its `url` is the loopback port's,
2742
+ and its `requestIP` and `timeout` know nothing of a request Vite took, so
2743
+ the default `ctx.ip` is `undefined`. A `page()` (Bun's HTML bundle) is not
2744
+ served: Vite answers the HTML
2745
+ ([The server](guide/typing-the-loaders.md#the-server-server)).
2746
+
2747
+ **Fix:** read `ctx.server` as optional, which also covers `app.request` in
2748
+ a test, and take nothing from its `url` or `requestIP` in dev:
2749
+
2750
+ ```ts
2751
+ // app/server.ts
2752
+ import { createServer } from '@softistx/alxia-react-router';
2753
+
2754
+ export default createServer({
2755
+ configure: (app) =>
2756
+ app.get('/api/uptime', ({ server, reply }) =>
2757
+ reply.ok({ pending: server?.pendingRequests ?? null }),
2758
+ ),
2759
+ });
2760
+ ```
2761
+
2762
+ Let Vite and React Router serve the HTML in dev; a `page()` is for an app
2763
+ without React Router.
2764
+
2765
+ ### A `publish` under `react-router dev` misses the sockets opened before an edit
2766
+
2767
+ Two clients in one room; after an edit to `app/server.ts`, a message one
2768
+ sends no longer reaches the other.
2769
+
2770
+ **Why:** an edit to the server makes a new app, and the plugin starts a
2771
+ new `Bun.serve` for it on the next upgrade or request, so that new connections use
2772
+ the new handlers. A socket opened before the edit stays on the previous
2773
+ server, with the handlers it opened with, and a topic is one server's.
2774
+
2775
+ **Fix:** reconnect the clients after an edit: reload their pages. From
2776
+ the build there is one server, and every socket shares its topics.
2777
+
2778
+ ### The build has a package's Node variant, not its `bun` one
2779
+
2780
+ A dependency ships a `bun` variant, and the server runs its other one.
2781
+
2782
+ **Why:** the plugin adds the `bun` condition, and the package's `exports`
2783
+ decides which of its conditions comes first: read top to bottom, the
2784
+ first one the build has wins. A package listing `node` or `import` before
2785
+ `bun` gives that variant, under the plugin as under Bun itself.
2786
+
2787
+ **Fix:** none in the config can reorder a package's `exports`; that is
2788
+ the package's to change. To check which file a condition picks, ask Bun:
2789
+
2790
+ ```sh
2791
+ bun -e "console.log(import.meta.resolve('some-package'))"
2792
+ ```
2793
+
2794
+ ### `request.url` in a loader is `http://` and the internal host behind a proxy
2795
+
2796
+ **Why:** a proxy that terminates TLS asks the app over plain HTTP, on an
2797
+ address of its own, and React Router reads the request as it reached the
2798
+ app unless the server trusts the proxy. Without `proxy`, or from a
2799
+ connection `trusted` does not name, the forwarded headers are ignored.
2800
+
2801
+ **Fix:** give `createServer` (or `alxia()`, for a server of your own) the
2802
+ proxies, and have the proxy set `X-Forwarded-Proto` and `X-Forwarded-Host`:
2803
+
2804
+ ```ts
2805
+ // app/server.ts
2806
+ import { trustProxy } from '@softistx/alxia';
2807
+ import { createServer } from '@softistx/alxia-react-router';
2808
+
2809
+ export default createServer({ proxy: trustProxy({ trusted: ['10.0.0.0/8'] }) });
2810
+ ```
2811
+
2812
+ React Router then gets its request at `originalUrl(ctx)`
2813
+ ([Behind a proxy](https://github.com/softistx/alxia/blob/develop/packages/core/docs/guide/serving.md#behind-a-proxy-proxy)).
2814
+
2815
+ ### An unhashed file under `public/assets/` is cached for a year
2816
+
2817
+ A file you put in `public/assets/` (a sprite, an icon) changes on a deploy,
2818
+ and visitors keep the old one.
2819
+
2820
+ **Why:** Vite copies `public/` into `build/client/`, and the client's files
2821
+ under `build/client/assets/` are served `public, max-age=31536000,
2822
+ immutable`, hashed or not. The worker's `cachingFor` agrees by default:
2823
+ everything under `/assets/` is `immutable`, cache-first.
2824
+
2825
+ **Fix:** keep unhashed files out of `assets/`: `public/icons/` is served for
2826
+ an hour and is `static` for the worker. If they must stay there, give
2827
+ `cachingFor` an `immutable` option that leaves their folder out, so the worker
2828
+ revalidates them ([the option](guide/pwa.md#what-the-worker-caches)),
2829
+ and expect the HTTP cache to hold them for a year until the file's name
2830
+ changes.
2831
+
2832
+ ### A cache the contract did not make is swept
2833
+
2834
+ Signing out, or a new worker activating, deletes a cache the app made itself.
2835
+
2836
+ **Why:** a contract owns every cache named exactly
2837
+ `<prefix>-<kind>-<version>`, kind being lowercase letters and digits and
2838
+ version having no `-`. That includes a kind the app retired (`my-app-pages-v0` is swept once
2839
+ it is not current). It is also why `app` and `app-admin` can share an origin:
2840
+ `app-admin-assets-v1` has one segment too many to be `app`'s. Contracts never
2841
+ take each other's caches; only a cache made by other code, such as
2842
+ `my-app-runtime-v1`, matches the shape and is swept.
2843
+
2844
+ **Fix:** name your own caches outside the shape. A name is outside it when it
2845
+ has more than `<kind>-<version>` after `<prefix>-`, with the prefix `my-app`:
2846
+ `my-app-runtime-v1-x`. A kind with an uppercase letter, `_` or `.`
2847
+ (`my-app-Runtime-v1`, `my-app-run_time-v1`), or a different prefix, is outside
2848
+ too.
2849
+
2850
+ ### The update notice never shows
2851
+
2852
+ A new version is deployed and the page offers no "Reload".
2853
+
2854
+ **Why:** the notice is offered only when a worker finished installing while
2855
+ an older one controls the page. A first install controls nothing, so it
2856
+ offers nothing; the next visit, with the first worker in control, does. And
2857
+ nothing is registered at all where the app does not call
2858
+ `registerServiceWorker` (for example while `useServiceWorker({ enabled })`
2859
+ is given `false`, as `import.meta.env.PROD` is under `react-router dev`). A
2860
+ tab that chose "Later" stays quiet until the next session.
2861
+
2862
+ **Fix:** build, serve and load the page twice, then deploy a change and load
2863
+ it again. In the console, `navigator.serviceWorker.controller` must not be
2864
+ `null` and `(await navigator.serviceWorker.getRegistration()).waiting` must
2865
+ hold the new worker.
2866
+
2867
+ ### The worker registers under `react-router dev`
2868
+
2869
+ The dev server serves stale code after an edit, or a page keeps an old
2870
+ version of itself, and `navigator.serviceWorker.controller` is not `null`.
2871
+
2872
+ **Why:** `useServiceWorker` registers whenever `enabled` is `true`, and the
2873
+ package does not know the mode: it never reads `import.meta.env`. A worker
2874
+ under a dev server caches the code you are editing.
2875
+
2876
+ **Fix:** pass the mode from the app, `useServiceWorker({ enabled:
2877
+ import.meta.env.PROD })` ([the hook](guide/pwa.md#in-react)). Then unregister
2878
+ the worker the dev server already took (DevTools, Application, Service
2879
+ Workers, Unregister) and clear its site data.
2880
+
2881
+ ### The service worker is not built
2882
+
2883
+ `react-router build` ends and there is no `build/client/service-worker.js`.
2884
+
2885
+ **Why:** `alxia()` builds no worker when the file is not at
2886
+ `app/service-worker.ts` (the `appDirectory` of `react-router.config.ts` may
2887
+ hold another) and no `worker` option names it, when `worker: false` is set,
2888
+ or when the version of `@softistx/alxia-react-router` is older than 0.10.
2889
+
2890
+ **Fix:** put the file at `app/service-worker.ts`, or name it with
2891
+ `alxia({ worker: 'app/pwa/worker.ts' })`, and update the package.
2892
+
2893
+ ### Offline, a client navigation to a route never visited shows the offline page
2894
+
2895
+ The page opens offline, but a link to a route the user never opened leads to
2896
+ `/offline.html`.
2897
+
2898
+ **Why:** React Router asks `/__manifest` for the routes a link needs, and the
2899
+ worker never caches that request.
2900
+
2901
+ **Fix:** set `routeDiscovery: { mode: 'initial' }` in `react-router.config.ts`,
2902
+ so the client has every route from its first load.
2903
+
2904
+ ### An update waits an hour
2905
+
2906
+ A new worker is deployed and tabs still run the old one for up to an hour.
2907
+
2908
+ **Why:** the worker's script was served with the client's hour of
2909
+ `Cache-Control`, so the browser's update check found the cached script.
2910
+ Either `noCache` is not declared, or it is declared in `configure`, which
2911
+ runs after the client's files: they answer first and the middleware never
2912
+ sees the request.
2913
+
2914
+ **Fix:** declare it in `beforeAll`
2915
+ ([serving the worker's script](guide/pwa.md#serving-the-workers-script)), and
2916
+ check with `curl -I https://your.app/service-worker.js` that `cache-control` is
2917
+ `no-cache`.
2918
+
2919
+ ### The worker cannot fetch another origin
2920
+
2921
+ The console reports `Refused to connect to 'https://api.example.com/…' because it violates the following Content Security Policy directive: "connect-src 'self'"` from the worker.
2922
+
2923
+ **Why:** `noCache` gives the worker's script `WORKER_POLICY`,
2924
+ `default-src 'none'; connect-src 'self'`: the worker fetches this site only.
2925
+
2926
+ **Fix:** if the worker really must reach another origin, serve the script
2927
+ with a wider policy through `revalidated(response, policy)` in a middleware of
2928
+ your own ([serving the worker's script](guide/pwa.md#serving-the-workers-script)),
2929
+ rather than loosening the pages' policy.
2930
+
2931
+ ### The manifest is in the wrong language
2932
+
2933
+ The installed app's name and description are in the default language,
2934
+ whatever the user chose.
2935
+
2936
+ **Why:** the browser fetches the manifest without cookies, so the `language`
2937
+ cookie never reaches the server. Only the link's query does.
2938
+
2939
+ **Fix:** link `manifestHref(language)` (`/manifest.webmanifest?lang=fr`), and
2940
+ read it with `manifestLanguage(url, supported, fallback)`; the fallback is a
2941
+ supported language the app resolves from the request's `Accept-Language`, not
2942
+ from the cookie ([the manifest route](guide/pwa.md#the-web-app-manifest-and-why-the-language-travels-in-lang)).
2943
+
2944
+ ### A form's own check shows the code (`todos.errors.…`) instead of words
2945
+
2946
+ A refinement with `params: { code: 'todos.errors.title-taken' }` shows the
2947
+ code itself, or the form library's generic text, where the API's words should
2948
+ be.
2949
+
2950
+ **Why:** `apiCodeResolver` returns the code unchanged when its `messages`
2951
+ store has no text for it in the page's language, and the form library then
2952
+ words the issue itself. In the browser the store holds only what the root's
2953
+ data brought: the code is not in that list (the app's `clientCodes`), or
2954
+ `ApiMessagesProvider` is not around the routes, or it was given another store
2955
+ than the resolver's.
2956
+
2957
+ **Fix:** add the code to the few the root sends, and wrap the routes with the
2958
+ provider on the same instance the resolver reads:
2959
+
2960
+ ```tsx
2961
+ <ApiMessagesProvider messages={apiMessages} value={loaderData.apiMessages}>
2962
+ <Outlet />
2963
+ </ApiMessagesProvider>
2964
+ ```
2965
+
2966
+ Check it with `apiMessages.messageOf('fr', code)` in the browser's console
2967
+ or a spec ([the catalogue store](guide/errors.md#the-catalogue-store)).
2968
+
2969
+ ### A message shows its `{braces}`
2970
+
2971
+ A refusal reads `{count, plural, one {One item} other {# items}} outside {name}.`
2972
+ or `Hello {name}`, braces and all.
2973
+
2974
+ **Why:** the `format` given to `createApiMessages` is not an ICU formatter
2975
+ (an identity function, a plain `replace`), or a value the message names is
2976
+ missing and the formatter handed back the raw message. `apiMessage` returns
2977
+ `undefined` for a message the formatter reported to `onError`, but a
2978
+ formatter that never calls it returns the text as it found it.
2979
+
2980
+ **Fix:** pass the app's ICU formatter, such as `@nxgt/material`'s
2981
+ `formatMessage`, and make it call `onError` for a message it cannot format:
2982
+
2983
+ ```ts
2984
+ const apiMessages = createApiMessages<'en' | 'fr'>({ format: formatMessage });
2985
+ ```
2986
+
2987
+ A value is missing when the API's `extensions.params` lacks an argument the
2988
+ message names; the same call in a spec shows which.
2989
+
2990
+ ### A refusal shows the API's raw message
2991
+
2992
+ A page shows `Variable "$email" got invalid value …` or another message the
2993
+ API worded for developers, instead of the app's words.
2994
+
2995
+ **Why:** the error has no API code (a raw `BAD_USER_INPUT`, from a check that
2996
+ failed before the API's validation layer), or a code that `isApiCode`
2997
+ rejects. Without `refused`, `createApiErrors` says the API's own message for
2998
+ such an error.
2999
+
3000
+ Versions before the camelCase patch also rejected a camelCase module
3001
+ (`userProfiles.errors.slug-taken`): upgrade, or pass `isApiCode`.
3002
+
3003
+ **Fix:** pass `refused`, the app's generic refusal; it replaces the raw
3004
+ message for every error that is not an API code
3005
+ ([wording a refusal](guide/errors.md#wording-a-refusal)):
3006
+
3007
+ ```ts
3008
+ export const apiErrors = createApiErrors<'en' | 'fr'>({
3009
+ messages: apiMessages,
3010
+ unavailable: (language) => translate('app.error.unavailable', language),
3011
+ refused: (language) => translate('app.error.refused', language),
3012
+ });
3013
+ ```
3014
+
3015
+ ### `apiRefusal` returns undefined
3016
+
3017
+ `apiErrors.apiRefusal(error, language)` gives `undefined` for a call that
3018
+ failed, and the action returns nothing useful.
3019
+
3020
+ **Why:** the error is neither an API error (`isApiErrorLike`) nor a 503
3021
+ `Response`: a network failure, a `TypeError` of the app's own code, a 404.
3022
+ `apiRefusal` words only what the API refused or could not be reached for.
3023
+
3024
+ **Fix:** rethrow what it does not word, so the route's error boundary shows
3025
+ it:
3026
+
3027
+ ```ts
3028
+ const refusal = apiErrors.apiRefusal(error, 'en');
3029
+ if (!refusal) throw error;
3030
+ ```
3031
+
3032
+ ### The error page shows no request id
3033
+
3034
+ The root's `ErrorBoundary` calls `errorRequestId(error)` and gets `undefined`,
3035
+ though the API logged the request.
3036
+
3037
+ **Why:** `routeError` carries the `requestId` the error already has; it never
3038
+ reads it from the network. An `ApiError` has none unless the code that called
3039
+ the API set it, and a thrown `Response` is turned into a route error only when
3040
+ it has the `x-request-id` header. A loader that returns `routeError(error)`
3041
+ instead of throwing it never reaches the boundary at all.
3042
+
3043
+ **Fix:** keep the id on the error where the API is called, and `throw` what
3044
+ `routeError` gives back
3045
+ ([loaders and the error page](guide/errors.md#loaders-and-the-error-page)):
3046
+
3047
+ ```ts
3048
+ import { requestIdOf, routeError } from '@softistx/alxia-react-router/errors';
3049
+
3050
+ // Your own call to the API, declared here as a stub.
3051
+ declare function call(): Promise<Response>;
3052
+
3053
+ export async function loader() {
3054
+ const response = await call();
3055
+ if (!response.ok) {
3056
+ // A Response of 401, 403, 404 or 503 with the header is a route error.
3057
+ throw routeError(response);
3058
+ }
3059
+ return { requestId: requestIdOf(response) };
3060
+ }
3061
+ ```
3062
+
3063
+ ### An action shows the error page
3064
+
3065
+ An action that calls `fetcherResult`, `fetcherRefusal`, `formRefusal` or `submitForm` ends on
3066
+ the route's error page instead of answering `{ ok: false }` or the form's
3067
+ errors.
3068
+
3069
+ **Why:** by design, these helpers answer only what the page can word. They
3070
+ throw `routeError(error)` for a 401 (the session code redirects to the sign-in
3071
+ first), for a failure that is not an API refusal (a network error, a bug of the
3072
+ app's own code), and, for `submitForm` only (not `formRefusal`, which answers a 404 as the
3073
+ form's message), for a 404 that names none of the
3074
+ form's fields: the record itself is gone, and no field message could say so.
3075
+
3076
+ **Fix:** none is needed for a 401 or a real failure: the error page is the
3077
+ right answer. For a 404 that is about a field, name it in `fieldOf`
3078
+ (`(path) => (path === 'todo.id' ? 'id' : undefined)`) so it sits under that
3079
+ field. For a refusal you would rather word yourself, build on `apiRefusal`,
3080
+ which returns `undefined` instead of throwing:
3081
+
3082
+ ```ts
3083
+ const refusal = apiErrors.apiRefusal(error, 'en');
3084
+ if (!refusal) throw error;
3085
+ return Response.json(
3086
+ { ok: false, error: refusal.message },
3087
+ { status: refusal.status },
3088
+ );
3089
+ ```
3090
+
3091
+ ### Behind a TLS proxy every action answers 403
3092
+
3093
+ Every action that reads JSON answers 403 `Cross-site request refused`
3094
+ in production, yet works under `react-router dev` and in the specs.
3095
+
3096
+ **Why:** `jsonActions()` (and `requireSameSite(request)` without `origin`) compares the browser's `Origin` (`https://app.example.com`)
3097
+ with the origin of `request.url`. Behind a proxy that terminates TLS the
3098
+ app is asked over plain HTTP on an internal host (`http://10.0.0.5:3000`),
3099
+ so no post matches. See also
3100
+ [`request.url` in a loader is `http://`](#requesturl-in-a-loader-is-http-and-the-internal-host-behind-a-proxy).
3101
+
3102
+ **Fix:** name the proxy with `createServer({ proxy: trustProxy(…) })`
3103
+ (`trustProxy` is `@softistx/alxia`'s; see
3104
+ [Behind a proxy](guide/customising-the-server.md#behind-a-proxy)). The
3105
+ catch-all hands React Router the URL `originalUrl` reads from the trusted
3106
+ proxy's `X-Forwarded-Proto` and `X-Forwarded-Host`, so an action's
3107
+ `request.url` already carries the public origin and `jsonActions()` needs no
3108
+ `origin`. Without a trusted proxy, or when the proxy does not send those
3109
+ headers, pass the public origin, as a string or as a getter read at each
3110
+ request (so a value set at startup is found):
3111
+
3112
+ ```ts
3113
+ import { jsonActions } from '@softistx/alxia-react-router/errors';
3114
+
3115
+ export const { readJson, requireJsonPost, readInput } = jsonActions({
3116
+ origin: () => process.env.APP_ORIGIN,
3117
+ });
3118
+ ```
3119
+
3120
+ When the getter returns `undefined`, the request's own origin is used, so
3121
+ development needs no setting. An empty string is not `undefined`: it is
3122
+ kept, and every request with an `Origin` is refused.
3123
+
3124
+ ### Right after start, refusals read in the API's words
3125
+
3126
+ For the first seconds after the server starts, a refusal shows the message
3127
+ the API worded (in its default language, say) instead of the page's language.
3128
+ It reads right a few seconds later.
3129
+
3130
+ **Why:** a language's catalogue is read on first use, and a request waits for
3131
+ it only up to `firstReadWaitMs` (1.5 seconds by default), counted from when the
3132
+ read started. A slow API, or a failed read, lets the request go on with the
3133
+ API's own words; the read carries on in the background (or is retried after
3134
+ `retryMs`), and the next request finds it held.
3135
+
3136
+ **Fix:** read both languages at startup, so the first request finds them held.
3137
+ In `server.ts`:
3138
+
3139
+ ```ts
3140
+ import { catalogue } from './catalogue.server';
3141
+
3142
+ catalogue.warm();
3143
+ ```
3144
+
3145
+ Raise `firstReadWaitMs` only if the page should wait longer for the first
3146
+ words; it holds every cold request that long when the API hangs.
3147
+
3148
+ ### `next` is always `/`
3149
+
3150
+ After signing in, the user lands on the home page, whatever page they came
3151
+ from, and `signInPath(next)` returns `/sign-in` with no `next`.
3152
+
3153
+ **Why:** `safeNext` refuses the value and falls back to `/`. It takes a path
3154
+ of this site only, so these are refused: a value that does not start with
3155
+ `/`, one that starts with `//` or holds a `\`, a space, a tab or a newline,
3156
+ a full URL (`https://…`), a value that resolves to another site once its
3157
+ `..` segments are applied, and one over 2000 characters. The usual cause is a
3158
+ `next` built from the full URL (`request.url`, `location.href`), or one
3159
+ that was percent-decoded twice.
3160
+
3161
+ **Fix:** pass the path and search alone:
3162
+
3163
+ ```ts
3164
+ import { signInPath } from '@softistx/alxia-react-router/session/model';
3165
+
3166
+ const url = new URL(request.url);
3167
+ throw redirect(signInPath(`${url.pathname}${url.search}`));
3168
+ ```
3169
+
3170
+ [Redirects that stay on the site](guide/session.md#redirects-that-stay-on-the-site)
3171
+ lists what is refused.
3172
+
3173
+ ### Sign-in loops on `http://localhost` in Safari
3174
+
3175
+ Signing in works in Chromium and Firefox. In Safari the app signs in, redirects, and lands back on the sign-in page, with no error.
3176
+
3177
+ **Why:** Safari (WebKit) drops a `Secure` cookie set over `http://localhost`, where the other browsers keep it. The session cookie never arrives, so the next request has no session.
3178
+
3179
+ **Fix:** pass `secure: false` in development. `secure: !import.meta.env.DEV` does it, and also drops the `__Host-` and `__Secure-` prefixes, which require `Secure`:
3180
+
3181
+ ```ts
3182
+ import { sessionCookies } from '@softistx/alxia-react-router/session';
3183
+
3184
+ export const cookies = sessionCookies({
3185
+ session: 'my-app_session',
3186
+ challenge: 'my-app_challenge',
3187
+ secure: !import.meta.env.DEV,
3188
+ });
3189
+ ```
3190
+
3191
+ Never write `secure: false` for a deployed app: the token would travel over HTTP.
3192
+
3193
+ ### A `__Host-` cookie is dropped
3194
+
3195
+ The browser's cookie panel shows no `__Host-` session cookie after a sign-in, or the response's `Set-Cookie` is ignored.
3196
+
3197
+ **Why:** a browser accepts a `__Host-` cookie only when it is `Secure`, has `Path=/` and no `Domain`, and the page is served over HTTPS (or `localhost` in Chromium and Firefox, never in Safari). The cookie the package writes always has `Path=/` and no `Domain`, so one of the others is wrong:
3198
+
3199
+ - the app is served over plain HTTP, such as a Docker image or a preview opened by its IP address, while `secure` is `true`;
3200
+ - a proxy in front of the app rewrites or strips `Set-Cookie`, or adds a `Domain` attribute;
3201
+ - another `Set-Cookie` header of the same name, set by the app, overwrites it.
3202
+
3203
+ **Fix:** serve the app over HTTPS, and keep `secure` `true` only there. Read `cookies.names.session` for the exact name, check the response header in the network panel, and make the proxy pass `Set-Cookie` as it is. In development over HTTP, `secure: !import.meta.env.DEV` sets an unprefixed cookie instead.
3204
+
3205
+ ### A wrong step-up code signs the user out
3206
+
3207
+ The user types a wrong code in the step-up dialog and lands on the sign-in page, instead of seeing "wrong code".
3208
+
3209
+ **Why:** `@softistx/janus-graphql` answers `CODE_INVALID` with HTTP 401. A caller that redirects to the sign-in page on any 401 takes the wrong code for a dead session, before `stepUp.confirm` sees the error.
3210
+
3211
+ **Fix:** in the app's caller, redirect to sign-in only for a session 401 (`UNAUTHENTICATED`), never for a step-up's `CODE_INVALID`. Or set `onSignedOut: 'sign-in'` on `stepUpSteps`: `route()` then redirects only a signed-out user. [Step-up](guide/session.md#call-the-step-up-with-a-caller-that-does-not-sign-out-on-a-401) has the full section.
3212
+
3213
+
3214
+ ### `TypeError: statePath(): a token page's path must be a path of this site with no query or fragment, starting with a single "/"; got ….`
3215
+
3216
+ ```
3217
+ TypeError: statePath(): a token page's path must be a path of this site with no query or fragment, starting with a single "/"; got "/auth/magic-link?…".
3218
+ ```
3219
+
3220
+ `statePath` throws it for its own `path`, and so do `ended()` and the `other.path` of `landByLink()`, which build their redirect with `statePath`: their error says `statePath(): …`, not their own name. The message names the call that was made.
3221
+
3222
+ **Why:** the page's `path` is the page without its token: the helpers add `?state=…` to it, and a redirect must stay on the site. A path with a query (`/auth/magic-link?token=…`), a fragment, a host or a second leading `/` is refused, which also keeps the token out of the redirect. The message prints the path only up to its `?` or `#`, so the token never reaches a log.
3223
+
3224
+ **Fix:** pass the route's own path, as a constant:
3225
+
3226
+ ```ts
3227
+ const PATH = '/auth/magic-link';
3228
+ await links.spendToken(run, { request, language, path: PATH, states });
3229
+ ```
3230
+
3231
+ ### `TypeError: linkArgs(): a token page's path must be a path of this site with no query or fragment, starting with a single "/"; got ….`
3232
+
3233
+ ```
3234
+ TypeError: linkArgs(): a token page's path must be a path of this site with no query or fragment, starting with a single "/"; got "/auth/magic-link?…".
3235
+ ```
3236
+
3237
+ `linkArgs` throws it for the `path` it is given, before it reads the body. The message names the call that was made.
3238
+
3239
+ **Why:** the page's `path` is the page without its token: the helpers add `?state=…` to it, and a redirect must stay on the site. A path with a query (`/auth/magic-link?token=…`), a fragment, a host or a second leading `/` is refused, which also keeps the token out of the redirect. The message prints the path only up to its `?` or `#`, so the token never reaches a log.
3240
+
3241
+ **Fix:** pass the route's own path, as a constant:
3242
+
3243
+ ```ts
3244
+ const PATH = '/auth/magic-link';
3245
+ await links.spendToken(run, { request, language, path: PATH, states });
3246
+ ```
3247
+
3248
+ ### `TypeError: spendToken(): a token page's path must be a path of this site with no query or fragment, starting with a single "/"; got ….`
3249
+
3250
+ ```
3251
+ TypeError: spendToken(): a token page's path must be a path of this site with no query or fragment, starting with a single "/"; got "/auth/magic-link?…".
3252
+ ```
3253
+
3254
+ `spendToken` throws it for the `path` of its options, before `run` is called. The message names the call that was made.
3255
+
3256
+ **Why:** the page's `path` is the page without its token: the helpers add `?state=…` to it, and a redirect must stay on the site. A path with a query (`/auth/magic-link?token=…`), a fragment, a host or a second leading `/` is refused, which also keeps the token out of the redirect. The message prints the path only up to its `?` or `#`, so the token never reaches a log.
3257
+
3258
+ **Fix:** pass the route's own path, as a constant:
3259
+
3260
+ ```ts
3261
+ const PATH = '/auth/magic-link';
3262
+ await links.spendToken(run, { request, language, path: PATH, states });
3263
+ ```
3264
+
3265
+ ### `TypeError: authLinks(): resetDone must be a path of this site, starting with a single "/"; got ….`
3266
+
3267
+ `authLinks` throws when the app starts.
3268
+
3269
+ **Why:** `resetDone` is where a password reset leads, so it goes through the
3270
+ same check as a sign-in's `next`: a URL, `//host` or a path without its
3271
+ leading `/` is refused.
3272
+
3273
+ **Fix:** pass a path of the app, with a query if it needs one:
3274
+
3275
+ ```ts
3276
+ authLinks({ signIn, resetDone: '/sign-in?password-reset=1' });
3277
+ ```
3278
+
3279
+ ### `Type '…' is not assignable to type 'undefined'` passing a context to a step
3280
+
3281
+ `tsc` refuses `signIn.signOut(request, { context: alxiaOf(context) })`, or the
3282
+ `context` of `revokeSession`, `landReplacing`, `signInStep`, `landByLink` or
3283
+ `afterReset`, with:
3284
+
3285
+ ```text
3286
+ Type 'AlxiaContextOf<…>' is not assignable to type 'undefined'.
3287
+ ```
3288
+
3289
+ **Why.** The flow was built with `signInFlow<Lang>(…)`. Giving one type
3290
+ argument stops TypeScript from inferring the second, `C`, the caller context,
3291
+ which then keeps its default, `undefined`. Every step's `context` is then
3292
+ typed `undefined`.
3293
+
3294
+ **Fix.** Write both type arguments, or none, and let `L` and `C` be inferred
3295
+ from `errors` and the annotated third parameter of `revoke`:
3296
+
3297
+ ```ts
3298
+ type Caller = AlxiaContextOf;
3299
+
3300
+ export const signIn = signInFlow<Lang, Caller>({
3301
+ // …
3302
+ revoke: (token, request, caller) => revokeAtApi(token, caller),
3303
+ });
3304
+ ```
3305
+
3306
+ ### A token page's token shows in a Referer or a search result
3307
+
3308
+ The token page's URL appears in another site's logs, or a search engine lists
3309
+ it.
3310
+
3311
+ **Why:** the page answered without `TOKEN_PAGE_HEADERS`, or only for its
3312
+ document and not its `.data` response.
3313
+
3314
+ **Fix:** set the headers on the route:
3315
+
3316
+ ```ts
3317
+ import { TOKEN_PAGE_HEADERS } from '@softistx/alxia-react-router/session';
3318
+
3319
+ export const headers = () => TOKEN_PAGE_HEADERS;
3320
+ ```
3321
+
3322
+ ### A subscription answers 401
3323
+
3324
+ `{"errors":[{"message":"Sign in to continue.","extensions":{"code":"UNAUTHENTICATED"}}]}`
3325
+
3326
+ **Why:** `getToken(request)` returned `null`, `undefined`, `''` or a token with a
3327
+ line break: the browser sent no session cookie (signed out, expired, or a
3328
+ cross-site request with a `SameSite=Lax` cookie), or `getToken` reads another
3329
+ cookie than the one the sign-in wrote.
3330
+
3331
+ **Fix:** return the token the loaders use, and send the cookie with the request
3332
+ (`credentials: 'include'` for a cross-origin client):
3333
+
3334
+ ```ts
3335
+ getToken: (request) => cookies.token(request),
3336
+ ```
3337
+
3338
+ ### A subscription answers 403 `This operation is not allowed.`
3339
+
3340
+ **Why:** `operationName` is not a key of `allow`. The proxy runs only the
3341
+ documents the server holds; a `query` the client sends is ignored.
3342
+
3343
+ **Fix:** list the name with its document, and send that name:
3344
+
3345
+ ```ts
3346
+ createSubscriptionProxy({ endpoint, allow: { RoomEvents: document }, getToken });
3347
+ ```
3348
+
3349
+ ### A subscription answers 403 `Cross-site request refused.`
3350
+
3351
+ **Why:** the request's `Origin` is not the app's own, or its `Sec-Fetch-Site` is
3352
+ `cross-site`, or `same-site` (another subdomain of the same site: only `same-origin` and `none` pass). Behind a TLS-terminating proxy
3353
+ the request's own origin can read `http://`.
3354
+
3355
+ **Fix:** call the route from the app's own pages, or give the proxy the public
3356
+ origin:
3357
+
3358
+ ```ts
3359
+ createSubscriptionProxy({ endpoint, allow, getToken, origin: 'https://app.example.com' });
3360
+ ```
3361
+
3362
+ ### A subscription answers 415 `Send the request as application/json.`
3363
+
3364
+ **Why:** a POST with another `Content-Type`, or none.
3365
+
3366
+ **Fix:** send `Content-Type: application/json` (`graphql-sse` does), or use GET.
3367
+
3368
+ ### A subscription answers 400 `The request is too large.`
3369
+
3370
+ **Why:** the body is over 64 KiB, the query string over 16 KiB, or `variables`
3371
+ over 16 KiB.
3372
+
3373
+ **Fix:** send less in `variables`; a document does not belong in the request,
3374
+ the server holds it.
3375
+
3376
+ ### A subscription answers 400 `The request is not valid JSON.`
3377
+
3378
+ **Why:** the POST body, or the `variables` parameter of a GET, is not JSON.
3379
+
3380
+ **Fix:** send `JSON.stringify({ operationName, variables })`, and `variables`
3381
+ JSON-encoded in a GET.
3382
+
3383
+ ### A subscription answers 400 `The request must be a JSON object.`, `Send an "operationName".`, `"operationName" must be a string.` or `"variables" must be an object.`
3384
+
3385
+ **Why:** the body is an array or a scalar, `operationName` is missing or not a
3386
+ string, or `variables` is not an object.
3387
+
3388
+ **Fix:** send `{ "operationName": "RoomEvents", "variables": { … } }`.
3389
+
3390
+ ### A subscription answers 500 `The proxy's upstream headers are not valid …`
3391
+
3392
+ **Why:** a value of `headers` (a forwarded `Accept-Language`, a secret from the
3393
+ environment) holds a line break, or a name is not a header name, or the
3394
+ `headers` function threw (for example `alxiaOf(context)` on a request served
3395
+ without alxia's context). The answer's text is fixed: nothing from the error
3396
+ reaches the browser.
3397
+
3398
+ **Fix:** trim or validate the value before it goes in `headers`, and guard the
3399
+ context (`context ? alxiaOf(context).ip : null`); read the error in your own
3400
+ log by catching inside the function.
3401
+
3402
+ ### A subscription answers 429 with `retryAfter`
3403
+
3404
+ The API's rate limit answered. The proxy passes it on and never retries.
3405
+
3406
+ **Fix:** have the client wait `Retry-After` seconds (also `retryAfter` in the
3407
+ body) before it subscribes again.
3408
+
3409
+ ### A subscription answers 502
3410
+
3411
+ **Why:** the API is unreachable, answered 5xx, or answered something that is
3412
+ not `text/event-stream` (a proxy in front of it, or a wrong `endpoint`).
3413
+
3414
+ **Fix:** post the document to the `endpoint` by hand with the same headers; it
3415
+ must answer with `Content-Type: text/event-stream`.
3416
+
3417
+ ### The stream ends with `The API stream failed.`
3418
+
3419
+ **Why:** the upstream stream broke, or sent an event of more than 1 MiB with
3420
+ no blank line ending it.
3421
+
3422
+ **Fix:** read the API's logs; a subscription's events are small and end with a
3423
+ blank line.
3424
+
3425
+ ### Events arrive in bursts, or the stream closes after a few seconds
3426
+
3427
+ **Why:** a proxy or CDN between the app and the browser buffers the response,
3428
+ or closes an idle connection (Bun's `idleTimeout`, 10 seconds by default,
3429
+ shorter than the 15 second `heartbeatMs`; a load balancer's timeout)
3430
+ because `heartbeatMs` is longer than it.
3431
+
3432
+ **Fix:** set `listen: { idleTimeout: 30 }` in `createServer` (and
3433
+ `idleTimeout: 30` on the API's `listen`), keep `heartbeatMs` shorter than the
3434
+ shortest idle timeout on the path, turn response buffering off for the
3435
+ route (nginx `proxy_buffering off`; the route already sends `X-Accel-Buffering: no`), and do not compress the
3436
+ route's responses.
3437
+
3438
+ ### The step-up confirm answers `throttled` with `retryAfter`
3439
+
3440
+ **When:** a code is refused with `extensions.reason: 'throttled'` (or a 429),
3441
+ sometimes with `attemptsLeft: 0`.
3442
+
3443
+ **Why:** the shared window of code attempts is spent. It is not a lockout of
3444
+ this challenge: its tries stay. Since 0.51, `attemptsLeft: 0` with no `reason`
3445
+ is a spent challenge (`error: 'expired'`), never a lockout, and `locked` is
3446
+ always `false`: a locked screen never shows anymore.
3447
+
3448
+ **Fix:** word `error: 'throttled'` from `retryAfter` (seconds) and let the
3449
+ user send the code again after it; do not treat `attemptsLeft: 0` as a lockout.
3450
+
3451
+ ```ts
3452
+ if (answer.error === 'throttled') showWait(answer.retryAfter); // seconds
3453
+ else if (answer.error === 'expired') askForNewCode();
3454
+ ```
3455
+
3456
+ ### The sign-in code page says "Invalid code" with no wait after many tries
3457
+
3458
+ **When:** the API limits second-factor tries per account and refuses past the
3459
+ limit with the invalid-code code, `extensions.reason: 'throttled'` and
3460
+ `retryAfter` (seconds), on a version before `signInFlow`'s `codeRefusal` read
3461
+ `reason`.
3462
+
3463
+ **Why:** `codeRefusal` only looked at the code and the tries left, so a
3464
+ throttled refusal read as a wrong code.
3465
+
3466
+ **Fix:** update `@softistx/alxia-react-router`. `codeRefusal` now answers "Too many
3467
+ tries, wait N min." (N is `retryAfter` rounded up to minutes), or "Try again
3468
+ later." with no `retryAfter`. Word it yourself with `signInFlow({ throttled })`.
3469
+
3470
+ ### The code field's Confirm stays enabled during a throttled wait
3471
+
3472
+ **When:** the sign-in's second-factor page shows "Too many tries, wait N min."
3473
+ but Confirm can still be pressed, on a version before 0.78.
3474
+
3475
+ **Why:** `signInStep`'s stayed answer carried only `formError`; the wait in
3476
+ seconds never reached the page.
3477
+
3478
+ **Fix:** update `@softistx/alxia-react-router`. A throttled refusal (`reason:
3479
+ 'throttled'`) now adds `throttled: true` and `retryAfter` (seconds, when the
3480
+ API gives them) beside `formError`: pass `error="throttled"` and `retryAfter`
3481
+ to the code field.
3482
+
3483
+ ### The step-up dialog stays on "confirming" after the code was accepted
3484
+
3485
+ **Why:** `useStepUpReplay` keeps the dialog open, confirming, until the answer
3486
+ of the replayed action arrives. A `replay()` that posts nothing (no pending
3487
+ action, a guard that returned early) produces no answer, so nothing ends it.
3488
+
3489
+ **Fix:** make `replay` post the refused action, or call `cancel()` when it has
3490
+ nothing to send.
3491
+
3492
+ ### The consent page's HTML has no `Cache-Control: no-store`
3493
+
3494
+ **When:** `curl -sI` on the consent page shows no `Cache-Control: no-store` on the document, while the `.data` requests of the same route carry it. The page holds the pending request and the viewer's details, so a shared cache could keep them.
3495
+
3496
+ **Why:** a route with no `headers` export gets only the loader's `Set-Cookie` headers on its document response; React Router copies the rest only through `headers`.
3497
+
3498
+ **Fix:** export the loader's headers from the consent route, as the [consent guide](guide/oauth.md#the-routes-server-side) does:
3499
+
3500
+ ```ts
3501
+ export function headers({ loaderHeaders }: Route.HeadersArgs) {
3502
+ return loaderHeaders;
3503
+ }
3504
+ ```
3505
+
3506
+ ### The consent page shows "expired" right after a decision
3507
+
3508
+ **When:** a viewer allows or denies a client and, before the browser reaches the client's callback, the page replaces itself with the expired state.
3509
+
3510
+ **Why:** the decision spends the request, so the route's loader reloaded after the action's submission and the API no longer knew the request.
3511
+
3512
+ **Fix:** export `consentShouldRevalidate` from `@softistx/alxia-react-router/oauth` as the route's `shouldRevalidate`:
3513
+
3514
+ ```ts
3515
+ import { consentShouldRevalidate } from '@softistx/alxia-react-router/oauth';
3516
+
3517
+ export const shouldRevalidate = consentShouldRevalidate;
3518
+ ```
3519
+
3520
+ ### A decision answers `ok: false` with an empty `error`
3521
+
3522
+ **When:** `useConsent` leaves `error` unset and the card does nothing after a click.
3523
+
3524
+ **Why:** an empty `error` goes with `stepUp: true` (the session needs confirming: the dialog opens, and the decision is posted again once confirmed) or `expired: true` (the API no longer knows the request). If neither dialog nor expired state shows, the page did not pass `dialogProps` to its step-up dialog or did not render `expired`.
3525
+
3526
+ **Fix:** render `<StepUpDialog {...dialogProps} />` and the `expired` state beside the card.
3527
+
3528
+ ### Approving a consent request answers 400 `Bad consent request`
3529
+
3530
+ **When:** the viewer clicks Allow and the action answers 400 with the body `Bad consent request`, though Deny works.
3531
+
3532
+ **Why:** the body is not `{ intent, id }` with a non-empty `id`, or, for an approval, its `bound` is wrong. With `requireBound: true` an approval without a `bound` is a 400, and so is a `bound` that is not `{ type, id }` of two non-empty strings. The usual cause is `onClick={approve}`: the hook then receives the click event, which binds nothing, so no `bound` is sent. A denial never needs one.
3533
+
3534
+ **Fix:** call `approve` with the picker's choice:
3535
+
3536
+ ```tsx
3537
+ <button type="button" onClick={() => approve({ type: 'workspace', id: workspace })}>Allow</button>
3538
+ ```
3539
+
3540
+ See [the consent guide](guide/oauth.md#binding-the-grant-to-something-the-user-picks).
3541
+
3542
+ ### Every consent request shows the expired state with `requireBinding`
3543
+
3544
+ **When:** `oauthConsent({ requireBinding: true })` answers `pending: null` (a 404) to a request the browser has just opened through `/oauth/authorize`.
3545
+
3546
+ **Why:** the browser holds no binding cookie. `mcpRelay` sets it only when the API's redirect names your own origin and your consent path, and `Location` is compared with the origin the client asked for, which is `http://` behind a proxy that ends TLS when `createServer({ proxy })` trusts none (the cookie is then plain, and the HTTPS page reads only the `__Host-` one). (A bad `origin` given to `oauthConsent` throws `TypeError: oauthConsent: origin must be an http(s) origin, got "…"` at start.) `oauthConsent` has the same blind spot: it names the cookie by its request's scheme unless it is given `origin`. Also: `consent: false`, a different `consent.path`, or a relay that does not sit in front of `/oauth/authorize`.
3547
+
3548
+ **Fix:** give the relay the public origin and the path, then check the `Set-Cookie` of the authorize answer (`curl -si '<app>/oauth/authorize?…'` shows `__Host-alxia_oauth_request=…`):
3549
+
3550
+ ```ts
3551
+ mcpRelay({ api, secret, consent: { origin: 'https://app.example', path: '/oauth/consent' } });
3552
+ oauthConsent({ /* … */ requireBinding: true, origin: 'https://app.example' });
3553
+ ```
3554
+
3555
+ ### `oauthConsent` treats a failing `find` as an expired request
3556
+
3557
+ **When:** every failure of `find` renders the expired page, or a real "unknown request" is thrown to the error page.
3558
+
3559
+ **Why:** only an API refusal that `notFound` accepts (a 404 by default) means "unknown request"; anything else is thrown.
3560
+
3561
+ **Fix:** pass `notFound: (error) => error.code === '<your API's code>'` when your API words it with another status.
3562
+
3563
+ ### `oauthGrants` `revoke` throws instead of answering `already-revoked` or `step-up`
3564
+
3565
+ **When:** revoking a connected app rejects with the API's error, though the grant is gone or the session needs confirming.
3566
+
3567
+ **Why:** `revoke` recognises an unknown grant by `notFound` (a 404 by default) and a stale session by the code `stepUpRequired` (`STEP_UP_REQUIRED` by default), both read from an `ApiError`. An API that words them with another status or code, or a call that throws something that is not an API error, is rethrown.
3568
+
3569
+ **Fix:** pass `notFound: (error) => error.code === '<your API's code>'` and `stepUpRequired: '<your API's code>'`, and let the API's errors through as they are.
3570
+
3571
+ ### The decision fails with "The API answered a redirect that is not an address"
3572
+
3573
+ **When:** approving or denying throws instead of sending the browser to the client's callback.
3574
+
3575
+ **Why:** `oauthConsent` follows a callback only when it is an `http:` or `https:` address (a `javascript:` or `data:` one would run in your page). The `redirectTo` your `approve` or `deny` returned was something else, or not a string.
3576
+
3577
+ **Fix:** return the API's `approveOAuthRequest` / `denyOAuthRequest` object as is (`{ redirectTo }`), and check the client's registered redirect URI is an http(s) address.
3578
+
3579
+
3580
+ ### `TypeError: mcpRelay: consent.path must start with "/"` or `consent.origin must be an http(s) origin`
3581
+
3582
+ **When:** the server declares `mcpRelay({ …, consent })`.
3583
+
3584
+ **Why:** `consent.path` is the consent page's path and `consent.origin` the app's public origin; either is malformed.
3585
+
3586
+ **Fix:** `consent: { path: '/oauth/consent', origin: 'https://app.example' }`, or `consent: false` to turn the binding cookie off.
3587
+
3588
+ ### An MCP or OAuth request answers 502
3589
+
3590
+ The API refused the connection, reset it, or sent no valid response.
3591
+
3592
+ **Fix:** check `api` and that the API is running and reachable from the app.
3593
+
3594
+ ### An MCP or OAuth request answers 413
3595
+
3596
+ The body is over the relay's limit: 256 KiB on `/mcp`, 64 KiB on `/oauth/*`.
3597
+ The API never saw the request.
3598
+
3599
+ **Fix:** send less. A client cannot raise the limit; it is part of
3600
+ `mcpRelay`.
3601
+
3602
+ ### An MCP or OAuth request answers 504
3603
+
3604
+ The API sent no response headers within `timeout` (60 000 ms by default).
3605
+
3606
+ **Fix:** check the API is up and that `api` points at it. A tool that really
3607
+ needs longer to start answering is a reason to pass a larger `timeout` to
3608
+ `mcpRelay`.
3609
+
3610
+ ### `403 {"error":"proxy_secret_required"}` on `/mcp` or `/oauth/token` of the API
3611
+
3612
+ **When:** an MCP client, or the relay, gets a 403 from the API on one of the relayed paths.
3613
+
3614
+ **Why:** the API guards `MCP_RELAY_PATHS` with `requireProxySecret`, and the request did not carry the secret header with the right value: it went to the API directly, or the relay's `secret` differs from the API's (a trailing newline, a rotation not finished).
3615
+
3616
+ **Fix:** reach the paths through the app, and give `mcpRelay` the same `secret` the API's `requireProxySecret` holds. See [the MCP guide](guide/mcp.md#let-the-api-accept-them-from-the-relay-alone).
3617
+
3618
+ ### The API sees the proxy's address for every MCP client
3619
+
3620
+ `mcpRelay` forwards `ctx.ip` as `X-Forwarded-For`. Behind a load balancer,
3621
+ `ctx.ip` is the balancer's unless the app is told to trust it.
3622
+
3623
+ **Fix:** `createServer({ proxy: trustProxy({ trusted: [...] }) })` from
3624
+ `@softistx/alxia`, listing the balancer's addresses.
3625
+
3626
+ ### `400 size_mismatch` from the media proxy
3627
+
3628
+ The `Content-Length` of the `PUT` is not a number (`-1`, `abc`). The API was not
3629
+ called. A browser's `fetch` of a `File` or `Blob` sets a valid one; a hand-made
3630
+ request or a proxy that rewrites headers may not.
3631
+
3632
+ **Fix:** send the real byte count, or none at all if `allowUnsized` is set.
3633
+
3634
+ ### `401 unauthenticated` from the media proxy
3635
+
3636
+ `getToken` returned nothing for a `PUT` or `DELETE`. A read goes on without a
3637
+ session; a write does not. The API was not called.
3638
+
3639
+ **Fix:** sign in; check `getToken` reads the cookie the session sets.
3640
+
3641
+ ### `403 forbidden` from the media proxy
3642
+
3643
+ The request is cross-site: a foreign `Origin`, or a `Sec-Fetch-Site` other than
3644
+ `same-origin` or `none`. The API was not called.
3645
+
3646
+ **Fix:** call `/media` from the app's own pages. Behind a proxy that changes
3647
+ the host, pass `origin` (the app's public origin).
3648
+
3649
+ ### `403 header_required` from the media proxy
3650
+
3651
+ A `PUT` or `DELETE` lacks a header listed in `requireHeaders`, or carries another
3652
+ value. The API was not called.
3653
+
3654
+ **Fix:** send the header from the page's upload code
3655
+ (`headers: { 'x-example-client': 'example-ui' }`), or remove it from
3656
+ `requireHeaders`.
3657
+
3658
+ ### Crop parameters of an upload do not reach the API
3659
+
3660
+ The proxy forwards no query string unless `forwardQuery` lists it.
3661
+
3662
+ **Fix:** `forwardQuery: ['x', 'y', 'size']` (or `true`), and send the parameters
3663
+ from the page with `uploadMedia(kind, file, { query: { x: 0.4, y: 0.6 } })`.
3664
+
3665
+ ### `404 not_found` from the media proxy
3666
+
3667
+ The path is not one of the media routes: the kind is not a key of `kinds`, the
3668
+ key is not a UUID, or the method does not fit the path (`PUT` takes no key,
3669
+ `DELETE` needs one). The API was not called.
3670
+
3671
+ **Fix:** add the kind to `kinds`, and check the URL is `/media/<kind>/<key>`.
3672
+
3673
+ ### `405 method_not_allowed` from the media proxy
3674
+
3675
+ `proxyMediaRead` takes `GET` and `HEAD`, `proxyMediaWrite` takes `PUT` and
3676
+ `DELETE`; the `Allow` header says which. Exporting both as the wrong one of
3677
+ `loader` and `action` gives this.
3678
+
3679
+ **Fix:** `export const loader = … proxyMediaRead`, `export const action = …
3680
+ proxyMediaWrite`.
3681
+
3682
+ ### `411 length_required` from the media proxy
3683
+
3684
+ The `PUT` has no `Content-Length`: its body is a stream (chunked), so its size
3685
+ is not known before the bytes go. The proxy refuses it before the API is
3686
+ called.
3687
+
3688
+ **Fix:** upload a `File` or `Blob`, which declares its length. A server-side
3689
+ caller that must stream sets `allowUnsized: true`, at the price of the API
3690
+ holding the body in memory up to the kind's `maxBytes`.
3691
+
3692
+ ### `413 too_large` from the media proxy, and the API saw nothing
3693
+
3694
+ The request declared a `Content-Length` over the `maxBytes` you gave for that
3695
+ kind in `kinds`. The body has `limit`, that `maxBytes`.
3696
+
3697
+ **Fix:** send a smaller file, or raise `maxBytes` in `kinds` together with the
3698
+ kind's own on the API.
3699
+
3700
+ ### `MediaUploadError` with reason `network`, `aborted` or `invalid_response`
3701
+
3702
+ `uploadMedia` (`@softistx/alxia-react-router/media/client`) rejects with a `MediaUploadError` whose `status` is `0` for `network` (the request got no answer: offline, a blocked request, a CSP `connect-src` that lacks `'self'`) and for `aborted` (the `signal` fired, or was already aborted). `invalid_response` is a 2xx whose body is not `{ key, contentType, size }`, which happens when an `onSuccess` hook of the route reshapes the answer: return `key`, `contentType` and `size` from it, or read the answer yourself. `timeout` is a 504 from the proxy, or `timeoutMs` elapsing.
3703
+
3704
+ ```ts
3705
+ import { MediaUploadError, uploadMedia } from '@softistx/alxia-react-router/media/client';
3706
+
3707
+ try {
3708
+ await uploadMedia('files', file, { timeoutMs: 120_000 });
3709
+ } catch (error) {
3710
+ if (error instanceof MediaUploadError && error.reason === 'aborted') return; // not a failure to show
3711
+ throw error;
3712
+ }
3713
+ ```
3714
+
3715
+ ### `MediaUploadError.retryAfter` is `undefined` on a 429
3716
+
3717
+ `retryAfter` is the `Retry-After` header of the refusal, in seconds (an HTTP date is converted to the seconds left). It is `undefined` when the answer has no such header or its value is neither whole seconds nor a date, so keep a default wait for that case. If a reverse proxy in front of the app drops the header, let it through; the media proxy itself forwards `Retry-After`. When the page and the API are on different origins, the browser hides the header unless the response sends `Access-Control-Expose-Headers: Retry-After`.
3718
+
3719
+ ```ts
3720
+ if (error instanceof MediaUploadError && error.reason === 'rate_limited') {
3721
+ const seconds = error.retryAfter ?? 60;
3722
+ }
3723
+ ```
3724
+
3725
+ ### A media file is fetched again on every page view
3726
+
3727
+ A middleware sets `Cache-Control: no-store` on every response, `/media`
3728
+ included, and replaces the API's year-long `private` cache header.
3729
+
3730
+ **Fix:** exempt the `/media` prefix from that middleware.
3731
+
3732
+ ### `500 proxy_misconfigured` from the media proxy
3733
+
3734
+ The `headers` function threw, or returned a name or value no header can hold,
3735
+ or `getToken` threw; `onRefusal` or `onSuccess` threw; `timeout` is not
3736
+ `Infinity` or a number from 1 to 2147483647; or `requireHeaders` names a header
3737
+ no request can hold (a space or a colon in the name). The `message` says which.
3738
+
3739
+ **Fix:** fix the function or the option; check that a header value has no line
3740
+ break.
3741
+
3742
+ ### `502 unavailable` from the media proxy
3743
+
3744
+ The API is unreachable (`api` is wrong or the API is down), the client left
3745
+ before the answer (the request was aborted), or the API answered with a
3746
+ redirect, which the proxy never relays to the browser. A failed read of the
3747
+ API's refusal body (the connection drops while `onRefusal` is waiting for it)
3748
+ also gives this 502, and it does not go through `onRefusal`.
3749
+
3750
+ **Fix:** check `api` and, for a redirect, that `apiPrefix` is the path the API
3751
+ mounts the routes at (a redirect to a trailing slash or another host is
3752
+ usually a wrong prefix).
3753
+
3754
+ ### `504 unavailable` from the media proxy
3755
+
3756
+ The API sent no response headers within `timeout` (60 s by default). The
3757
+ upstream request was aborted. An upload is answered only after its whole body,
3758
+ so a large file on a slow link can reach it.
3759
+
3760
+ **Fix:** find why the API is slow; for large uploads raise `timeout` on the
3761
+ options.
3762
+
3763
+ ### `Blocked request. This host ("…") is not allowed.`
3764
+
3765
+ Vite's dev or preview server answers it, with a 403.
3766
+
3767
+ **When:** the app is opened on a hostname other than `localhost`, such as a
3768
+ dev tunnel's public name.
3769
+
3770
+ **Why:** Vite only serves `localhost` and `.localhost` unless
3771
+ `server.allowedHosts` (and `preview.allowedHosts`) lists the host.
3772
+
3773
+ **Fix:** list the host in `DEV_ALLOWED_HOSTS`, comma-separated (a leading dot
3774
+ allows the subdomains too), or in the `allowedHosts` option of `alxia()`:
3775
+
3776
+ ```sh
3777
+ DEV_ALLOWED_HOSTS=my-app-mac.example.com bun run dev
3778
+ ```
3779
+
3780
+ ```ts
3781
+ alxia({ allowedHosts: ['my-app-mac.example.com'] });
3782
+ ```
3783
+
3784
+ `.example.com` lets any subdomain reach the dev server; prefer exact names.
3785
+
3786
+ See [Dev tunnels](../README.md#dev-tunnels-and-other-hostnames).
3787
+
3788
+ ### `HelpPanel` stays on `loading` and shows no sheet
3789
+
3790
+ The help button reports `loading: true` after an open and the sheet never
3791
+ appears. No error is raised.
3792
+
3793
+ **When:** `load` resolved a bundle with neither `language` nor
3794
+ `fallbackLanguage` (default `en`) as a key.
3795
+
3796
+ **Why:** the panel has no flows to show, so it keeps waiting rather than
3797
+ opening an empty sheet.
3798
+
3799
+ **Fix:** key the bundle by the languages the app speaks, or pass
3800
+ `fallbackLanguage` for one it has:
3801
+
3802
+ ```ts no-check
3803
+ <HelpPanel fallbackLanguage="fr" load={() => import('./help').then((m) => m.bundle)} />
3804
+ ```
3805
+
3806
+ ### `HelpPanel`: "Property 'sheetProps' is missing" or "Type '{ ... }' is not assignable to type 'undefined'"
3807
+
3808
+ Two compile errors on the same prop, depending on the sheet:
3809
+
3810
+ - `Property 'sheetProps' is missing in type ... but required in type ...`
3811
+ - `Type '{ itemId: string; }' is not assignable to type 'undefined'` (on `sheetProps`)
3812
+
3813
+ **Why:** `HelpPanel` is generic over the props of the sheet `loadSheet` resolves.
3814
+ A sheet declaring required props beyond `HelpPanelSheetProps` makes `sheetProps`
3815
+ required; a sheet with none takes no `sheetProps`.
3816
+
3817
+ **Fix:** match the two. Pass `sheetProps` for a sheet that needs data, or drop
3818
+ it, or add the props to the sheet's type, for one that does not:
3819
+
3820
+ ```tsx no-check
3821
+ // the sheet is `HelpPanelSheetProps & { itemId: string }`
3822
+ <HelpPanel loadSheet={() => import('./help-sheet')} sheetProps={{ itemId }} /* … */ />
3823
+ ```
3824
+
3825
+ See [passing data to the sheet](guide/help.md#passing-data-to-the-sheet-sheetprops).
3826
+
3827
+ ### `HelpPanel` reports a `loadSheet` module without a default export
3828
+
3829
+ `onLoadError` receives an error saying `loadSheet` must resolve a module with a
3830
+ default export, and the next open retries.
3831
+
3832
+ **When:** `loadSheet` resolves a module with no `default` export.
3833
+
3834
+ **Why:** the panel renders the default export of the module.
3835
+
3836
+ **Fix:** export the sheet as the module's default, taking `HelpPanelSheetProps`
3837
+ (see the [lazy panel](guide/help.md#the-lazy-panel-helppanel)).