Skip to content

feat: sample site and CORS for widget API routes (#31) - #61

Open
WanKim00 wants to merge 4 commits into
devfrom
30-dxfeature-package-the-ticket-form-as-an-embeddable-script-with-a-site-tag
Open

WanKim00 wants to merge 4 commits into
devfrom
30-dxfeature-package-the-ticket-form-as-an-embeddable-script-with-a-site-tag

Conversation

@WanKim00

@WanKim00 WanKim00 commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • Add a sample partner site (sample-site/) served on a different origin (pnpm sample-site → http://localhost:4000)
  • Add a plain-JS widget experiment (public/widget-test.js) that calls the ITS API cross-origin with the site tag
  • Add server/middleware/widget-cors.ts: enables CORS only for widget routes (/api/health, /api/widget/**)
  • Add /api/widget to PUBLIC_PREFIXES in server/middleware/auth.ts so widget routes skip the session check

How to test

  1. pnpm dev (ITS on :3000)
  2. pnpm sample-site (sample site on :4000)
  3. Open http://localhost:4000, click the blue button
  4. Console shows [ITS widget] Server response: {...} with no CORS errors
  5. curl -i http://localhost:3000/api/users still returns 401 with no CORS headers

Part of #31
Refs #19

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

Labels

None yet

Projects

None yet

1 participant