fix(questionnaires): fix public vendor form failing to load#444
Merged
Conversation
publicApiBaseURL appended /api/v1 onto NEXT_PUBLIC_API_URL, which already contains it, producing a double-prefixed /api/v1/api/v1 request that 404s. Also unmount /respond/:token from requireActivePlan: it ran for any visitor whose browser carries a session cookie (e.g. the workspace owner previewing their own link), 402ing a token-gated public route that vendors with no Retrieva account must reach. Moved both routes to a new unguarded questionnairePublicRoutes router mounted ahead of the plan gate.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
publicApiBaseURLappended/api/v1ontoNEXT_PUBLIC_API_URL, which already contains it, producing a double-prefixed/api/v1/api/v1/...request that 404s for the vendor-facing/q/:tokenform.requireActivePlanwas applied to the whole/api/v1/questionnairesmount, including the public/respond/:tokenroutes. When the visiting browser carries a session cookie (e.g. the workspace owner previewing their own generated link from apaused/past_dueorg), this returned 402 on a route that's supposed to be reachable by vendors with no Retrieva account at all./respond/:tokenroutes into a newquestionnairePublicRoutes.js, mounted unguarded inapp.jsahead ofoptionalAuth/requireActivePlan, matching the existing "unguarded" pattern for auth/organizations/billing.Fixes the reported error on
https://retrieva.online/q/<token>: "Unable to load questionnaire. Please try again."Test plan
npx vitest run tests/unittest/questionnaireController.test.js— 33 passednpx vitest run src/tests/questionnaires-api.test.ts(frontend) — 23 passeddocker compose up -d): created a real questionnaire, sent it for a token, then via Playwright onhttp://localhost:3000/q/<token>:/api/v1/questionnaires/respond/<token>→ 200, form renders with real DORA questions/api/v1/questionnaires/respond/<token>(Save & Continue) → 200, partial answer persisted in MongoDB/api/v1/api/v1/questionnaires/respond/<token>now 404s (vs 402)planStatus=pausedstill gets 200 on the public form, while other paid routes (e.g./workspaces) correctly still 402