fix: consent banner fails open on API error (500/403)
The consent check endpoint (/consent/check) returns 500 via the proxy when the backend returns 403 (missing JWT forwarding). Previously this caused the banner to show permanently since consentCheck was undefined. Now isError = true hides the banner (fail-open strategy — don't block users when backend is unavailable).
This commit is contained in:
@@ -19,12 +19,12 @@ export function ConsentBanner() {
|
||||
const t = useTranslations("consent")
|
||||
const [marketingChecked, setMarketingChecked] = useState(false)
|
||||
|
||||
const { data: consentCheck, isLoading } = useConsentCheckQuery()
|
||||
const { data: consentCheck, isLoading, isError } = useConsentCheckQuery()
|
||||
const grantMutation = useGrantConsentMutation()
|
||||
const deleteMutation = useDeleteAccountMutation()
|
||||
|
||||
// Don't show if still loading or consent already granted
|
||||
if (isLoading || consentCheck?.hasDataProcessingConsent) {
|
||||
// Don't show if loading, errored (fail open), or consent already granted
|
||||
if (isLoading || isError || consentCheck?.hasDataProcessingConsent) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user