I added session replay to mixpanel, but the /record endpoint through my client-side proxy is returning 401. I am new to debugging mixpanel issues
Hi Meryl H., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> đź‘‹
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
A 401 error from the /record endpoint when using a client-side proxy for Mixpanel Session Replay typically indicates an authentication or authorization issue. Here are the steps you should take to debug and resolve this: 1. Check Your Project Token Ensure that the project token used in your Mixpanel initialization matches the one in your Mixpanel project settings. An incorrect token will prevent data from being accepted by Mixpanel’s servers, resulting in 401 errors. You can verify your token in your project settings see: Troubleshooting FAQ.2. Proxy Configuration Make sure your proxy is correctly forwarding all necessary headers, especially the Authorization header if used. The proxy should not strip or alter headers required by Mixpanel. Also, ensure that the proxy is routing requests to the correct Mixpanel endpoint and not blocking or modifying the request in a way that would cause authentication to fail see: Debugging CORS Errors.3. CORS and Headers Double-check that your proxy is configured to handle CORS properly and is forwarding all required headers (Authorization, Content-Type, etc.) to the /record endpoint. Missing or altered headers can result in 401 or 415 errors see: Debugging CORS Errors.4. Initialization Confirm that you are initializing Mixpanel with the correct options and that the api_host (or serverURL) is set to your proxy domain. For example:
js
mixpanel.init('YOUR_PROJECT_TOKEN', {
api_host: 'https://<YOUR_PROXY_DOMAIN> '
});
```LBKS [see: Tracking Via Proxy (JavaScript)](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#tracking-via-proxy)LBKS5. **Debugging Tools**
Use your browser’s developer tools to inspect the network requests. Look at the request headers and payload sent to the /record endpoint via your proxy. Compare these with requests sent directly to Mixpanel’s default endpoints to spot discrepancies [see: Debugging CORS Errors](https://docs.mixpanel.com/docs/tracking-best-practices/debugging#understanding-cors-errors).LBKS6. **Fallback Test**
As a troubleshooting step, try switching back to the default Mixpanel endpoint (removing the proxy) to see if the issue persists. If it works without the proxy, the problem is likely with your proxy configuration [see: Debugging CORS Errors](https://docs.mixpanel.com/docs/tracking-best-practices/debugging#understanding-cors-errors).
If you continue to experience issues after these checks, consider enabling debug logging in your SDK and reaching out to Mixpanel Support with your initialization code, proxy configuration, and relevant logs for further assistance see: Troubleshooting FAQ.Let me know if you need more specific guidance on any of these steps!
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Can you tell which headers are required for /record
