[Webkit-unassigned] [Bug 231928] New: Show HTTP status code in CORS messages logged to devtools console that can indirectly result from HTTP errors

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Oct 18 18:08:06 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=231928

            Bug ID: 231928
           Summary: Show HTTP status code in CORS messages logged to
                    devtools console that can indirectly result from HTTP
                    errors
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Enhancement
          Priority: P2
         Component: Web Inspector
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: mike at w3.org
                CC: achristensen at apple.com, cdumez at apple.com,
                    inspector-bugzilla-changes at group.apple.com,
                    katherine_cheney at apple.com

### Problem
 When a CORS request is sent to a server and the server responds with a 4xx or 5xx HTTP status code in the response, and the response doesn’t include the Access-Control-Allow-Origin header, the browser will always log a CORS error message to the devtools console — but may not (or even usually doesn’t) also log the HTTP status code to the console.

As a result, many (or most) developers who are in the process of trying to troubleshoot the server-side CORS config (on the server the request was sent to) only see the CORS error — but don’t see the 4xx or 5xx HTTP status code — and so then often (or usually) assume that there’s a mistake in their CORS config, when in fact the actual cause is that a 4xx or 5xx error occurred.

For some evidence and discussion of that problem, see the following:

* https://stackoverflow.com/questions/54795541/503-return-from-server-is-branded-as-cors-violation-by-chrome
* https://davidtruxall.com/misleading-cors-errors/

The effect of that problem is that, every day, it causes hundreds if not thousands of developers to waste hours trying to troubleshoot and identify mistakes in their server CORS config — mistakes they never find, because in fact their existing CORS config is already working as expected and instead the real cause is some 400 or 500 or 502 or whatever.

The main reason those developers see CORS errors logged to the devtools console in those cases is that many (or most) runtimes/server systems by default do not add application-set response headers to 4xx and 5xx responses — including the Access-Control-Allow-Origin response header. (For example, Apache and nginx do not; in order to make them add the Access-Control-Allow-Origin response header to 4xx or 5xx errors, the `always` keyword needs to be added to the header-setting directive.)

### Proposed solution
Make the HTTP status be included in all CORS messages that might get logged when a 4xx or 5xx error occurs. That means the following:

* Failed to load resource: Origin foo is not allowed by Access-Control-Allow-Origin

* Failed to load resource: Preflight response is not successful

The proposal here is that in the case of, for example, a 500 error, those messages would instead be:

* Failed to load resource: Origin foo is not allowed by Access-Control-Allow-Origin. Status code: 500

* Failed to load resource: Preflight response is not successful. Status code: 500

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20211019/2b1a7f8e/attachment-0001.htm>


More information about the webkit-unassigned mailing list