Replies: 8 comments 13 replies
-
Overall it looks fantastic! Looking forward to using this for some of my use-cases at work, especially during frontend development when I don't want to wait for the API changes to be ready, I can mock the response headers like cache-control etc, as per my requirement. I haven't tried this yet, but got few questions,
I can give more feedback after I try this feature. Amazing work guys, as always! |
Beta Was this translation helpful? Give feedback.
-
I'd love to have override Request headers too.
some cases are covered by chrome://flags or cli args etc. but modify request could solve every specific / general purpose and increase debugability & DX since devtools is handy for devs rather than restarting chrome or installing additional toos. |
Beta Was this translation helpful? Give feedback.
-
Hey @wolfib @jecfish, Thanks for putting this all together. I am Sachin - Founder & CEO, of Requestly - An Open Source developer tool for Intercepting & Modifying all parts of HTTP requests & responses like Headers, API responses, API request Body, URL redirects, Request throttles, Injecting scripts, Recording HTTP Sessions, etc. Requestly has ~175K installs in Chrome Store & I'd love to offer help in building this right from my experience in interacting with these users and understanding their use cases. As @Jxck mentioned, there are plenty of use cases for modifying HTTP request headers. I don't have complete context if there's a technical constraint/limitation to building it but Ideally, the support should be provided for modifying both HTTP request & response headers. Here are some use cases that I know of people use modify request headers for
You can't add the Authorization request header from Postman/Insomnia because it is a part of your workflow, you are not sending this request in Isolation. You need some capability like a browser extension (like Requestly) or In-built dev tools capability. Another thing is we should also provide the capability to remove a response header. A couple of examples
Not sure if changing the value to empty string works in these cases though. Another learning is we should provide an indicator of when a header is modified on the page. Even if the devtools is open, we should let the users know that some override has happened be it - Headers or files. Many users reported that once they configure any header modification in Requestly, it is very difficult to know if any request is modified in the background. We solved it by changing the extension Icon to green. The icon when any rule is applied on the page Thought to share this Idea in case we can do something like this to let people know when an override happens. Hope this is helpful and Cheers to making web development, testing & debugging more easier. |
Beta Was this translation helpful? Give feedback.
-
Great work team 🎉! Some use cases I would have for overriding http headers:
|
Beta Was this translation helpful? Give feedback.
-
Looks promising! I was actually working on a task last week were I wanted to override the response data instead of the response headers. Hopefully this is something that is going to be supported as well in the near future! I already see a lot of potential use cases for it that would speed up development & testing a lot. 😍 |
Beta Was this translation helpful? Give feedback.
-
Sounds a great idea, and really useful to have it directly in the browser. I've been using tools like Charles Proxy to do similar, but our development macs are getting so locked down, using third party software like Charles is becoming less possible, so having this feature will be great. |
Beta Was this translation helpful? Give feedback.
-
Regex support more convenient i think. |
Beta Was this translation helpful? Give feedback.
-
After several weeks of discussion, the RFC for Response Header Overrides is now closed. Here is our attempt at summarizing the feedback we received both here and on other channels (@ChromeDevTools Twitter, Mastodon, LinkedIn, in person). We have implemented these feature requests:
Apart from that, we would like to highlight a few nice to have, but non-blocking feature requests we received repeatedly:
There are other UX improvement suggestions as well, we’ll consider adding them, possibly in follow-up releases. |
Beta Was this translation helpful? Give feedback.
-
Author: Wolfgang Beyer (@wolfib)
Posted: Feb 13, 2023
Status: Complete
Chrome bug tracker: https://crbug.com/1288023
The goal of this RFC is to validate the design with the community, and to solicit feedback on open questions.
Complete: This RFC is now complete. See a summary here.
Motivation
HTTP headers let the client and the server pass additional information with an HTTP request or response. This meta-information is important for a website’s functionality and security. Until now, editing HTTP headers required having access to the actual web server, which often made it difficult to quickly experiment with changes to HTTP headers.
With the new Header Overrides feature in DevTools, you can specify response headers locally. When Chrome (with DevTools open and header overrides enabled) loads a page for which header overrides are defined, Chrome behaves as if these overridden HTTP headers are coming from the remote server. This allows you to locally experiment with different values for HTTP response headers.
Goals and Non-Goals
Goals:
Non-Goals:
Try out the Prototype
The prototype is available from Chrome 111 onwards. To check your current browser version, type
chrome://version
in your address bar (Install Chrome Beta, Dev, or Canary if your current browser version is lower.)Click on the Settings icon > Experiments tab > enable the Local overrides for response headers experiment.
Modify HTTP Response Headers in the Network Panel
Follow the steps below to modify HTTP Response Headers:
Getting started. Click on a request in the Network panel. In the Headers pane, scroll to the Response Headers section. Hover over a response header and click on the edit button.
One-Time setup. This setup process is only necessary for your first visit. Pick a folder on your local disk to store local overrides in, and allow DevTools to access this folder. If you have already set up local overrides before, these steps will be skipped and you can continue right away. Watch this video for complete setup walkthrough.
Edit an existing response header. You can now edit the value of any response header by simply clicking on it. The edited headers have a green background.
Add a custom header. Scroll to the end of the Response Headers section. Click on + Add header button to add a new header. It has a green background.
Delete or Reset a header. Delete any new custom headers you added with the trash icon button. Deleted headers will be highlighted in a red background colour. If you have made changes to an existing header, clicking the trash icon button means revert it back to its original value. DevTools does not support completely removing an existing response header for now (But you can set a header to an empty string
“”
). Let us know in the comments if you have any use-case for that.Reload the page. Your edits are automatically saved. To apply your changes, simply reload the page.
Advanced: Override response headers for multiple requests in the Sources panel
You might encounter scenarios where you want to modify the response headers of multiple requests. Instead of editing the headers of each request individually, there is a way to create header overrides which automatically apply to multiple requests.
Getting started. Open a network request with override headers. In the Headers pane, click on the Header Overrides link in the Response Headers section to open the
.headers
file in the Sources panel.Add override rules. In the
.headers
file, click Add override rule to add a new rule. In this example, I added a new rule that appliesx-custom-header: hello
to all resources under the same domain. The rule supports wildcards characters (e.g. '*' for zero or more characters, '?' for exactly one character). For example, a*.jpg
applies to all resource locations which end with.jpg
.Save the changes and reload the page. You need to manually save the changes with
Command/Control
+S
. Reload the page to apply the changes..headers
file manually in theOverrides
pane under the Sources panelExample use cases
These are just a few examples of what you can do with header overrides. We would love to hear about your own use cases. Feel free to share them in the comments below.
Cross-Origin Resource Sharing (CORS) Headers
The Cross-Origin Resource Sharing standard relies on headers, which let servers describe which origins are permitted to read their responses. When those headers are missing or mis-configured, you encounter error messages such as the one in the image below.
You can add the suggested
Access-Control-Allow-Origin
header as an override, to see if the proposed solution is working as intended. Once you have verified this locally, you still need to upload the changes to the server, so that other users see those changes as well. Try it yourself with this CORS demo or watch this video on overriding the CORS header.Permissions-Policy Headers
The HTTP Permissions-Policy header provides a mechanism to allow and deny the use of browser features. The screenshots below are showing an example in which a
Permissions-Policy
header is overridden to allow the geolocation API to be used. Try it yourself with this geolocation demo.Cross-Origin Isolation Headers
Cross-origin isolation is a requirement for unlocking powerful features such as the SharedArrayBuffer. To make your website cross-origin isolated, COOP (Cross-Origin-Opener-Policy) and COEP (Cross-Origin-Embedder-Policy) headers need to be configured correctly. Here is an example in which iframes are not loading due to a mis-configured CORP-header. Using a header override we can confirm that setting the header value to
cross-origin
fixes the issue:Questions for Discussion
In addition to general feedback, we would like to collect feedback on the following specific questions:
What use cases are you seeing for header overrides? While we have plenty of ideas ourselves of scenarios in which header overrides could be useful, we are very interested in knowing about your actual use cases.
When using header overrides, are you experiencing any bugs? Please report any bugs you are discovering when using header overrides. Since this is a completely new feature, the chances of encountering something unforeseen are higher than usual. Reporting bugs helps us improve the experience as fast as possible.
FAQ
Can I edit header names in the Network Panel?
You can only edit the header name of a header you just created with the + Add header button. After refreshing the page, you cannot edit the header name anymore. Just delete the header entirely and add a new header with the desired name.
Why does my edited header still show up even after I deleted it?
If you edit the
.headers
file directly and change theApply to
, you cannot delete these overrides from the Network Panel anymore. To remove these headers, go to the.headers
file and make your changes there.Beta Was this translation helpful? Give feedback.
All reactions