Users are sometimes redirected to the /login page after clicking the "Save subscriptions" button. This is a bug that occurs because the global /api/account SWR user has an empty ID when we try to make that PUT /api/account request which results in the following server-side error on Vercel:
[PUT] /api/account
08:22:52:85
verbose: Verifying request body...
verbose: Verifying authentication cookie...
verify-auth: 111.040ms
verbose: Updating document...
error: API encountered: Error: Value for argument "documentPath" is not a valid resource path. Path must be a non-empty string.
at Object.validateResourcePath (/var/task/node_modules/@google-cloud/firestore/build/src/path.js:414:15)
at CollectionReference.doc (/var/task/node_modules/@google-cloud/firestore/build/src/reference.js:1931:20)
at updateUserDoc (/var/task/.next/server/pages/api/account.js:1311:84)
at updateAccount (/var/task/.next/server/pages/api/account.js:2157:38)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async account (/var/task/.next/server/pages/api/account.js:2192:7)
at async apiResolver (/var/task/node_modules/next/dist/next-server/server/api-utils.js:8:1)
at async Server.handleApiRequest (/var/task/node_modules/next/dist/next-server/server/next-server.js:66:462)
at async Object.fn (/var/task/node_modules/next/dist/next-server/server/next-server.js:58:580)put-account: 113.678ms
// Re-validate if we haven't gotten any account data yet. This fixes
// an issue where the profile view would locally update to an empty
// `User()` *before* our `/api/account` endpoint could respond. SWR
// cancelled the `/api/account` mutation in favor of the empty one.
await mutate('/api/account', updated.toJSON(), loggedIn === undefined);
Users are sometimes redirected to the
/login
page after clicking the "Save subscriptions" button. This is a bug that occurs because the global/api/account
SWR user has an empty ID when we try to make thatPUT /api/account
request which results in the following server-side error on Vercel:This can probably be fixed by implementing something similar to
tutorbookapp/tutorbook
inpages/_app.tsx
: