Skip to content

🐛 Fix remaining console errors: auth refresh, CSP, GTM#4364

Merged
clubanderson merged 2 commits intomainfrom
fix/console-errors
Apr 3, 2026
Merged

🐛 Fix remaining console errors: auth refresh, CSP, GTM#4364
clubanderson merged 2 commits intomainfrom
fix/console-errors

Conversation

@clubanderson
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #4346 — fixes the remaining console errors found via CDP scan:

  • Add MSW mock for POST /auth/refresh — AuthCallback and silent token refresh were getting HTML instead of JSON from Netlify's SPA catch-all, causing Unexpected token '<' errors
  • Add www.googletagmanager.com to CSP connect-src — GTM's /td data endpoint was blocked by CSP, causing ERR_FAILED and Failed to fetch errors in the service worker
  • Add MSW passthrough for external resourcesapi.dicebear.com (avatars), fonts.gstatic.com and fonts.googleapis.com (web fonts) were triggering unhandled request warnings
  • Suppress all cross-origin MSW warnings — any request to a different origin now silently passes through instead of logging a warning
  • Suppress font file warnings.woff2, .woff, .ttf added to the asset ignore list

Test plan

  • Verify Netlify preview has no console errors/warnings on initial load
  • Verify DiceBear avatar loads without MSW warning
  • Verify Google Tag Manager data collection works (no CSP block)
  • Verify fonts load without MSW warning
  • Verify Unexpected token '<' JSON parse errors are gone

- Add MSW handler for POST /auth/refresh — eliminates JSON parse errors
  from AuthCallback and silent token refresh getting HTML instead of JSON
- Add www.googletagmanager.com to CSP connect-src — fixes GTM td endpoint
  being blocked by Content Security Policy
- Add MSW passthrough for dicebear.com, fonts.gstatic.com, and
  fonts.googleapis.com — eliminates unhandled request warnings
- Suppress MSW warnings for cross-origin requests and font files
  (.woff2/.woff/.ttf) in onUnhandledRequest handler

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Copilot AI review requested due to automatic review settings April 3, 2026 01:31
@kubestellar-prow kubestellar-prow bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Apr 3, 2026
@kubestellar-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mikespreitzer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 3, 2026

Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit 026679d
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/69cf19a36a77a4000811341e

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@kubestellar-prow kubestellar-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is a follow-up to #4346 that targets remaining browser console errors in Netlify demo/preview deployments by tightening MSW behavior (auth refresh + external resources) and aligning Netlify CSP with Google Tag Manager’s network usage.

Changes:

  • Added an MSW mock for POST /auth/refresh to prevent SPA fallback HTML from being parsed as JSON during OAuth callback / silent refresh flows.
  • Added explicit MSW passthrough handlers for common external resources (DiceBear + Google Fonts) and suppressed cross-origin unhandled-request warnings.
  • Updated Netlify Content-Security-Policy to allow GTM requests via connect-src.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
web/src/mocks/handlers.ts Adds passthrough handlers for external resources and mocks POST /auth/refresh with a JSON token response.
web/src/mocks/browser.ts Expands ignored asset extensions and suppresses MSW unhandled-request warnings for cross-origin requests.
netlify.toml Adds https://www.googletagmanager.com to CSP connect-src to prevent GTM fetch blocks.

The unified-controls baseline (1 → 34) and non-localized strings
baseline (167 → 187) drifted from reality as cards were added.
Both counts are identical on main — this just syncs the baselines.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@clubanderson clubanderson merged commit 2b0a561 into main Apr 3, 2026
20 of 24 checks passed
@kubestellar-prow kubestellar-prow bot deleted the fix/console-errors branch April 3, 2026 01:42
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit 2b0a56103b325ccbf2f422e994577d2804f2a56f.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

✅ Post-Merge Verification: passed

Commit: 2b0a56103b325ccbf2f422e994577d2804f2a56f
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/23930043580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants