Overview Open Chrome DevTools What's New in DevTools DevTools tips Simulate mobile devices with Device Mode Performance insights: Get actionable insights on your website's performance Lighthouse: Optimize website speed Animations: Inspect and modify CSS animation effects Changes: Track your HTML, CSS, and JavaScript changes Coverage: Find unused JavaScript and CSS Developer Resources: View and manually load source maps CSS Overview: Identify potential CSS improvements Issues: Find and fix problems Media: View and debug media players information Memory Inspector: Inspect ArrayBuffer, TypedArray, DataView, and Wasm Memory. Network conditions: Override the user agent string Security: Understand security issues Search: Find text across all loaded resources Sensors: Emulate device sensors WebAuthn: Emulate authenticators Customize DevTools Engineering blog
Overview Open Chrome DevTools What's New in DevTools DevTools tips Simulate mobile devices with Device Mode Performance insights: Get actionable insights on your website's performance Lighthouse: Optimize website speed Animations: Inspect and modify CSS animation effects Changes: Track your HTML, CSS, and JavaScript changes Coverage: Find unused JavaScript and CSS Developer Resources: View and manually load source maps CSS Overview: Identify potential CSS improvements Issues: Find and fix problems Media: View and debug media players information Memory Inspector: Inspect ArrayBuffer, TypedArray, DataView, and Wasm Memory. Network conditions: Override the user agent string Security: Understand security issues Search: Find text across all loaded resources Sensors: Emulate device sensors WebAuthn: Emulate authenticators Customize DevTools Engineering blog

Override files and HTTP response headers locally

Published on

With local overrides, you can keep the changes you make in DevTools across page loads. You can also override HTTP response headers.

How it works:

  • When you make changes in DevTools, DevTools saves a copy of the modified file to a folder you specify.
  • When you reload the page, DevTools serves the local, modified file, rather than the network resource.
Important

You can also save your changes directly to source files. See Edit and save files with Workspaces.

Limitations

Local overrides work for network response headers and for most file types, with a couple of exceptions:

  • DevTools doesn't save changes made in the DOM tree of the Elements panel.
  • If you edit CSS in the Styles pane, and the source of that CSS is an HTML file, DevTools won't save the change.

Instead, you can edit HTML files in the Sources panel.

Enable or disable local overrides

Specify a folder where DevTools will keep your changes:

  1. Open DevTools on a page.

  2. Go to Sources > Overrides and click Add. Select folder for overrides.

    The 'Select folder for overrides' button.
  3. Pick a folder and, when prompted, allow DevTools access to it.

Local overrides enabled in a specified folder.

To view the files served by the server again, clear Cleared checkbox. Enable local overrides at any time.

To delete all the files with changes, click Clear..

Make changes

Make changes to your code, for example, edit CSS in the Elements panel, or JavaScript in Sources.

DevTools saves the modified files, lists them in Sources > Overrides, and shows you the Saved. icon next to the overridden files.

Overridden files listed in the Sources > Overrides and icons next to these files.

Track your local changes

You can keep track of all the changes you make in one place—the Changes drawer tab.

Override HTTP response headers

From the Network panel, you can override HTTP response headers without the access to the web server.

With response header overrides, you can locally prototype fixes for various headers, including but not limited to:

To override a response header:

  1. Open DevTools, for example, on this demo page.

  2. Go to Network, select a request from the table, open Headers > Response Headers.

  3. Hover over a response header value and click Edit..

    The edit button next to a response header.
  4. If prompted, pick a folder for DevTools to save changes to and allow access.

  5. Modify a header.

    This example adds the Access-Control-Allow-Origin: * header to get rid of a CORS error.

    Modifying an existing header value, adding a new one, and removing an override.
    • To edit a header value, click it.
    • To add a new header, click Add. Add header.
    • To remove a header override, click Delete. next to it. This removes the headers you added or reverts modified values back to original values.

    DevTools highlights modified headers in green and removed overrides in red.

  6. Refresh. Refresh the page to apply the changes.

Edit all response header overrides

To edit all header overrides in one place:

  1. Click Saved. Header overrides next to the Response Headers section.

    The Header overrides link next to the Response Headers section.

    DevTools takes you to the corresponding .headers file in Sources > Overrides.

  2. Edit the .headers file:

    Editing the .headers file.
    • To add a new override rule, click Add override rule. A rule here is a set of headers and values and a single or multiple request to apply them to.

      You can use wildcards to specify multiple requests at once. Designate multiple characters with * and a single one with ?.

    • To add a header-value pair to a rule, hover over another pair and click Add..

    • To revert a header value, remove an added header or a rule, hover over it and click Delete..

  3. Save the .headers file with Command / Control + S.

  4. Refresh. Refresh the page to apply the changes.

Published on Improve article

This site uses cookies to deliver and enhance the quality of its services and to analyze traffic. If you agree, cookies are also used to serve advertising and to personalize the content and advertisements that you see. Learn more about our use of cookies.