Now I can see the issue - the extension is sending requests from a chrome-extension:// origin to the Vercel deployment. The 401 error is happening because the Next.js middleware or API routes are blocking the chrome extension origin. Let me check the existing API routes and add CORS headers to allow the extension.
I need to add CORS headers to all API routes to allow requests from the Chrome extension. Let me create a middleware file to handle this, and also add CORS headers directly to the API routes for OPTIONS (preflight) requests.
Now update the log API route to include CORS headers:
Now update the status route:
Now update the health route:
I've added CORS support to all three API endpoints that the extension uses. The changes include:
/lib/cors.ts) that generates appropriate headers for requests from Chrome extensions, Firefox extensions, localhost, and Vercel deploymentsOPTIONS handler to each route to handle preflight requests/api/log, /api/status, and /api/health endpointsThe extension should now be able to successfully send requests to your platform without getting 401 errors due to CORS restrictions. The CORS configuration allows requests from any chrome-extension:// or moz-extension:// origin, which will enable your extension to communicate with the API.
I pulled the latest changes from v0/dipherent1-f365251a in Echo-platform.
You can send messages while the preview loads