When something goes wrong with a website – whether it is a broken design, slow performance, shows an error message or something else, it is sometimes difficult to find the exact cause of the issue just by looking at the page. That’s where the HAR files or browser console errors come into play. These in-built browser features allow the tech experts or developers to dig deeper into what’s happening behind the scenes. In some cases, our support team may ask for the HAR file and console logs to help troubleshoot the issue.
In this blog, we’ll show you a simple and step-by-step guide on how to generate and save the HAR file and browser console logs so you can share that with your developer or Sucuri support team for troubleshooting.
When you visit a website, the browser loads various resources like images, scripts, styles and more to display the website. A HAR (HTTP Archive) file keeps a detailed record of all the requests that browser makes to the server during the website visit. It captures things like the time it takes for each request, server response, the IP address of the server where the request was sent, the size of the data, headers, cookies, and other useful data.
You can export the HAR file on all modern web browsers. Here’s how to generate and save an HAR file on different browsers.
Please note that the HAR file may contain sensitive information. Before sharing it, we suggest removing things like authentication tokens, cookies or personal details from the HAR file. You can use a text editor to edit the HAR file.
Sometimes, the browser blocks certain scripts from loading due to CORS issues or there are some Javascript errors or security warnings that don’t appear up in the HAR file. Console errors can give us a better idea of what’s going wrong on the client side. In some cases, we need those logs along with the HAR file to troubleshoot the issue. Here’s how you can save those logs so and share it for troubleshooting:
When sanitizing a HAR file, start by redacting authentication tokens (like access tokens or API keys) in request headers to protect sensitive credentials. If cookies were sent, sanitize them as they may contain session data. Check the request body for sensitive info like usernames and passwords and redact query parameters containing private data such as tokens or user IDs.
Additionally, ensure response content, including names and email addresses, is sanitized. Remove any API keys or secrets in headers that could grant unauthorized access. Lastly, redact any other sensitive data, such as IP addresses or internal service information.
Here is the example of the HAR file before sanitization:
{ "log": { "version": "1.2", "browser": { "name": "Firefox", "version": "136.0.2" }, "entries": [ { "request": { "headers": [ { "name": "Authorization", "value": "AccessToken xyz789secretkey" }, { "name": "Cookie", "value": "session_id=xyz2739372;" } ], "url": "https://example.com/user?token=abc123456&userid=7296493", "body": "{\"username\":\"john_miller\",\"password\":\"Password@123\"}" }, "response": { "content": { "text": "{\"userId\": 7296493, \"email\": \"[email protected]\", \"name\": \"John Miller\", \"address\": \"Abc, City, Country\"}" } } } ] } }
After sanitization:
{ "log": { "version": "1.2", "browser": { "name": "Firefox", "version": "136.0.2" }, "entries": [ { "request": { "headers": [ { "name": "Authorization", "value": "AccessToken REDACTED" }, { "name": "Cookie", "value": "session_id=REDACTED;" } ], "url": "https://example.com/user?token=REDACTED&userid=REDACTED", "body": "{\"username\":\"REDACTED\",\"password\":\"REDACTED\"}" }, "response": { "content": { "text": "{\"userId\": 7296493, \"email\": \"REDACTED\", \"name\": \"REDACTED\", \"address\": \"REDACTED\"}" } } } ] } }
For securely sharing a sanitized HAR file, you may consider using secure file sharing services such as Google Drive, Dropbox, or OneDrive. Make sure to share the link only with the people you want to give access to and password protect that file for extra security.