Automattic / wp-calypso

The JavaScript and API powered WordPress.com
https://developer.wordpress.com
GNU General Public License v2.0
12.43k stars 1.99k forks source link

Change admin interface style CORS error #94222

Open zaerl opened 1 month ago

zaerl commented 1 month ago

Quick summary

Switching the admin interface style generates a CORS error and an error panel.

Steps to reproduce

  1. Visit one atomic site like https://wordpress.com/settings/general/__SITE__
  2. Select "Default style" (if not already in that style)
  3. Select "Classic style" and save
  4. You will be directed to wp-admin.php. Now go back to /settings/general/__SITE__ and select "Defaul style"

What you expected to happen

This to not appear: image

Access to XMLHttpRequest at 'https://wordpress.com/settings/general/__SITE__'
(redirected from 'https://public-api.wordpress.com/wpcom/v2/sites/__ID__/hosting/admin-interface?_envelope=1') 
from origin 'https://public-api.wordpress.com' has been blocked by CORS policy: Response to preflight request
doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

What actually happened

The switch happened, but the error appeared.

Impact

Most (> 50%)

Available workarounds?

No but the platform is still usable

If the above answer is "Yes...", outline the workaround.

No response

Platform (Simple and/or Atomic)

Atomic

Logs or notes

Chrome 128.0.6613.115 Site ID: 61074952

Copons commented 1 month ago

AFAICS, the incorrect notice appears on simple sites as well.

However, I'm considering this a low-priority issue.

When users select the Classic interface, they are redirected to wp-admin, and from then on, they will remain on wp-admin. We still leave the Default (Calypso) interface accessible for fallbacks and workarounds, but it's not part of regular flows. Therefore, we presume that users who intend to switch to the Default interface will do so from wp-admin, where the toggle works fine and doesn't display the error notice. The fact that they can do it from the Default interface is unexpected.

cc @arthur791004, who recently worked on the admin interface toggle (https://github.com/Automattic/wp-calypso/pull/88459) if you have further insights about the Untangling behaviour.