Skip to content

fix(analytics): add proxy route to bypass CORS/adblock issues#30

Merged
jal-co merged 3 commits into
mainfrom
fix/openpanel-nextjs-sdk
Apr 24, 2026
Merged

fix(analytics): add proxy route to bypass CORS/adblock issues#30
jal-co merged 3 commits into
mainfrom
fix/openpanel-nextjs-sdk

Conversation

@jal-co

@jal-co jal-co commented Apr 24, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes OpenPanel analytics 401 errors by proxying requests through the app's own server.

Changes

  • Add /api/[...op] catch-all route handler using createRouteHandler from @openpanel/nextjs/server
  • Update OpenPanelComponent to use proxy endpoints:
    • apiUrl="/api/op"
    • scriptUrl="/api/op/op1.js"

Why

Direct API calls to api.openpanel.dev were returning 401 due to CORS restrictions (domains not whitelisted). The proxy approach:

  1. Routes tracking requests through our own domain
  2. Bypasses ad blockers that block third-party analytics
  3. Eliminates need to whitelist every dev/preview/prod domain in OpenPanel dashboard

Testing

Verified locally with curl:

POST /api/op/track → 200 OK

jal-co added 2 commits April 24, 2026 08:36
- Use OpenPanelComponent for client-side tracking
- Replace Umami server-side tracking with OpenPanel
- Update client-side track helper for window.op
- Add /api/[...op] route handler using createRouteHandler from @openpanel/nextjs/server
- Update OpenPanelComponent to use proxy endpoints (apiUrl, scriptUrl)
- Fixes 401 errors from direct API calls without whitelisted domains
@jal-co jal-co merged commit b335f93 into main Apr 24, 2026
2 checks passed
@jal-co jal-co deleted the fix/openpanel-nextjs-sdk branch April 24, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant